LoadImage Fails to Load Certain JPEGs
See original GitHub issueDescribe the bug LoadImage fails to correctly load certain JPEGs. The produced array contains streaked information. Test image included:
.
To Reproduce
im=LoadImage(image_only=True)("bad_image.jpg")
plt.imshow(im[0],cmap="gray")
This produces
Expected behavior
Image should look like the attached image but comes out corrupted when viewed with matplotlib, using plt.imread
does work.
Environment (please complete the following information):
- Ubuntu
- Python version 3.7
- MONAI version 62903b6924e572edfb0d44ce333dd0251e659bfe
- CUDA/cuDNN version 11, 7.5
- GPU Titan Xp
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (13 by maintainers)
Top Results From Across the Web
load-image fails with error 4077 while trying to load high ...
While trying to load high-resolution images with the LOAD-IMAGE function, error 4077 will be encountered in 32bit OpenEdge.
Read more >Failed to load image error code 2 - Stack Overflow
i am fairly new to programming in general and i am having trouble understanding the code given to me as part of ...
Read more >LoadImage limitation - MSDN - Microsoft
LoadImage does not load JPEG file formats. It only loads BMP file formats. Use the Windows Imaging Component (WIC) to load images, ...
Read more >loadImage() / Reference / Processing.org
Loads an image into a variable of type PImage. Four types of images ( .gif, .jpg, .tga, .png) images may be loaded. To...
Read more >PHPickerViewController fails to load image - Apple Developer
Some image formats (e.g. webp) can't be loaded as UIImage objects. Use loadFileRepresentation instead.Some images are not available locally on your device if ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
From looking at the ITK code further I think
keep_axis
should always be False. It would only be True if data was being read in Fortran-ordering as opposed to C-ordering, simply reversing the shape will just cause the memory view to be interpreted in a transposed order. In GetArrayViewFromImage ifkeep_axis
is True the ordering of the shape is reversed but the returned Numpy array still interprets the underlying memory segment in C-ordering, this is why we get the transposed image as I showed.I think the
keep_axis
parameter is not explained correctly since it should only be True if memview is a view into Fortran-ordered segments, the documentation does not state this. Further if this is the case it would be better to leave the shape reversed (ie. in HW(D)C ordering) and set theorder
argument fornumpy.array
toF
to use Fortran-ordering internally.The
axes
referenced in thekeep_axes
argument toitk.array_view_from_image
are referencing the order of indexing of the spatial dimensions. We will add a new kwarg toitk.array_view_from_image
to specify whether the channels should be contiguous or interleaved. Until that is released, we can use #1147