Comments (10)
I get this error for the second example:
error[E0599]: no method named `to_ndarray` found for struct `DecodedPixelData` in the current scope
--> src/main.rs:17:30
|
17 | let ndarray = pixel_data.to_ndarray::<u16>()?;
| ^^^^^^^^^^ method not found in `DecodedPixelData<'_>`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `hello_cargo` (bin "hello_cargo") due to 1 previous error
These are my dependencies in Cargo.toml:
[dependencies]
dicom = "0.6.3"
dicom-object = "0.6.3"
dicom-pixeldata = "0.2.2"
ndarray = "0.15.6"
from dicom-rs.
I suspect that there is some trait version mismatch. Can you try importing open_file
like this instead?
use dicom_object::open_file;
from dicom-rs.
Thank you for your quick response. Unfortunately, this did not solve the problem.
I have changed the code to:
fn main() -> Result<(), Box<dyn std::error::Error>> {
//use dicom::object::open_file;
use dicom_object::open_file;
use std::env;
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
return Err("Usage: program_name <DICOM file path>".into());
}
let file_path = &args[1];
let obj = open_file(file_path)?;
use dicom_pixeldata::PixelDecoder;
let image = obj.decode_pixel_data()?;
let dynamic_image = image.to_dynamic_image(0)?;
dynamic_image.save("out.png")?;
Ok(())
}
with this Cargo.toml
[dependencies]
dicom = "0.6.3"
dicom-object = "0.6.3"
dicom-pixeldata = "0.2.2"
cargo run
results in the same error. I have also tried to run cargo clean
before compiling the code.
My OS information are:
System Version: macOS 14.4
Kernel Version: Darwin 23.4.0
from dicom-rs.
If anything, there may be something going on at the Cargo.lock. Here are a few more steps to try and resolve the situation:
- Run
cargo tree -d
to see if there are duplicate dependencies. Runcargo update
and inspect the dependency tree again. - If after this it still won't compile, then I would recommend removing the parent
dicom
crate and picking the specific crates that you need. This is the rule of thumb that I personally follow: when picking specificdicom-*
crates, remove the parent crate.
from dicom-rs.
I have solved the issue. The method "to_dynamic_image" is part of the image feature of pixeldata, which seems to be not enabled by default.
It works with this dependencies:
[dependencies]
dicom-object = "0.6.3"
dicom-pixeldata = { version = "0.2.2", features = ["image"] }
I have also tried it with the dependencies dicom = "0.6.3"
with use dicom::object::open_file;
and use dicom::pixeldata::PixelDecoder;
. I assume that the feature "image" is not activated in there.
from dicom-rs.
Oh yes, I must have overlooked that detail in your Cargo.toml. Converting to an image object requires the image
feature, since that brings an extra set of dependencies. This is mentioned in the root crate documentation.
I'm afraid that this is by design, so there isn't much one can do here, other than improve the way that documentation is generated to clarify the features required for those methods to exist.
from dicom-rs.
No worries. Thank you for your support.
How can I enable the feature in the root crate?
I have tried this, but it does not work.
[dependencies]
dicom = { version = "0.6.3", features = ["image"] }
from dicom-rs.
For that to work, dicom
itself needs to re-export the Cargo feature into its own feature table. While this parent crate was designed to facilitate simple use cases, it is true that it has some shortcomings such as this one.
If anything, one can add more Cargo features to dicom
. I agree that adding image
and ndarray
could be useful.
from dicom-rs.
Thank you for your support. It is a great library anyway. I will close this ticket now.
from dicom-rs.
Your feedback is appreciated! I have provided said re-exports in #469, to be delivered in the next version.
from dicom-rs.
Related Issues (20)
- Adding private data elements (with creator) HOT 4
- dicom-transfer-syntax-registry does not build on Windows by default HOT 1
- Extended offset table support
- Support for multiple character repertoires (extended character sets) HOT 1
- Could not compile openjp2 HOT 10
- Issue when trying to open a DICOM file. HOT 2
- DICOM naive datetime retrieval HOT 6
- Latest version fails to build for android HOT 5
- Unusual Image Generation from RLE DICOM Files HOT 4
- Wrong VR assumed when reading pixel padding in Implicit VR dataset
- Support resolving BulkDataURIs
- Non-deterministic behavior in dicom-storescu function check_presentation_contexts HOT 10
- Starting the discussion on async support HOT 3
- Storescp promiscuous mode HOT 1
- ERROR dicom_findscu: status code from response is missing HOT 3
- Very slow association with invalid adresses - Need to use custom timeout during connecting HOT 1
- Disable feature 'jpeg2k' in dicom-transfer-syntax-registry HOT 2
- DICOM Files with Large Number of Frames HOT 4
- Version of openjp2 causing issue in new projects HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dicom-rs.