question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LoadImage Fails to Load Certain JPEGs

See original GitHub issue

Describe the bug LoadImage fails to correctly load certain JPEGs. The produced array contains streaked information. Test image included:

bad_image .

To Reproduce

im=LoadImage(image_only=True)("bad_image.jpg")
plt.imshow(im[0],cmap="gray")

This produces

result

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:closed
  • Created 3 years ago
  • Comments:17 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ericspodcommented, Sep 14, 2020

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 if keep_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 the order argument for numpy.array to F to use Fortran-ordering internally.

0reactions
thewtexcommented, Oct 27, 2020

The axes referenced in the keep_axes argument to itk.array_view_from_image are referencing the order of indexing of the spatial dimensions. We will add a new kwarg to itk.array_view_from_image to specify whether the channels should be contiguous or interleaved. Until that is released, we can use #1147

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found