Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling multichannel 3D stacks #998

Closed
DiegoPerezDones opened this issue Feb 15, 2022 · 11 comments
Closed

Handling multichannel 3D stacks #998

DiegoPerezDones opened this issue Feb 15, 2022 · 11 comments
Labels

Comments

@DiegoPerezDones
Copy link

Hello evryone, I am trying to load a microgrpah composed of three channels but the native load function in the package keeps interpreting it wrongly.

img = load("my_path")
imgg = channelview(img)
imgg_graysacle = Gray.(imgg)

When I try to visualize each of the different channels it only has signal in the first of them.

I checked with imageJ how each channel should look like and it seems that for different slices the function is loading the info from different channels.

The image is a .tif hyperstack.

Thanks in advance for your help!

@johnnychen94
Copy link
Member

a microgrpah composed of three channels but the native load function in the package keeps interpreting it wrongly.

What do you mean by "interpreting it wrongly"? Maybe you can provide some basic information about the image you're using? For instance, summary(img) should be informative.

When I try to visualize each of the different channels it only has signal in the first of them.

Also, what steps you did to visualize the image channel?

@DiegoPerezDones
Copy link
Author

What do you mean by "interpreting it wrongly"? Maybe you can provide some basic information about the image you're using? For instance, summary(img) should be informative.

Basically what I mean is that I am unable to visualize it as in ImageJ, I cannot acces each channel and obtain the expected output. summary(img) returns this:

julia> summary(img)
"647×678×252 Array{RGB{N0f16},3} with eltype RGB{N0f16}"

Also, what steps you did to visualize the image channel?

As I am using Juno, the only step I need to visualize is to acces the array:

imgg_grayscale[1,:,:,20]
imgg_grayscale[2,:,:,20]
imgg_grayscale[3,:,:,20]

Only the first one returns an image with signal, i.e. not completely black. I have checked the rest of them and apparently the pixel values is 0 which should not

@johnnychen94
Copy link
Member

Does this mean you get an all-zero channel after loading it even before visualization?

Because there are multiple Image IO backends. Can you check if using TIffImages directly works?

using TiffImages
TiffImages.load(filepath)

If it is still the all-zero case, there might be some issues with your specific image file and TiffImages. In that case, providing an example image would be helpful to diagnose.

@DiegoPerezDones
Copy link
Author

Does this mean you get an all-zero channel after loading it even before visualization?

Exactly. Apart from that it seems to be taking the pixel values in each slice (z) from different channels randomly, meaning that in slice 21 I'd be getting the information from original channel 1 and for slice 57 for example the info from channel 3, which is at least weird.

Because there are multiple Image IO backends. Can you check if using TIffImages directly works?

using TiffImages
TiffImages.load(filepath)

Yeah I've tried loading with TiffImages backend and the probelm stills.

If it is still the all-zero case, there might be some issues with your specific image file and TiffImages. In that case, providing an example image would be helpful to diagnose.

If you don't mind I can send you the image I am trying to load and I will be very grateful if you could help me.

https://drive.google.com/file/d/1JEDVJXh6yV5V5WU7qyvk_xBd4E1_rInJ/view?usp=sharing

Thanks in advance!

@johnnychen94
Copy link
Member

I suppose this is a TiffImages issue, @tlnagy can you help check this?

using PyCall
using TiffImages

skimageio = pyimport("skimage.io")
cv2 = pyimport("cv2")

img_skimage = skimageio.imread("channels_24_1_R1.5.tif");
img_tiffimages = TiffImages.load("channels_24_1_R1.5.tif");

size(img_skimage) # UInt8: (84, 647, 678, 3)
size(img_tiffimages) # RGB{N0f16}: (647, 678, 252)

image

image

@tlnagy
Copy link
Contributor

tlnagy commented Feb 17, 2022

What's the output of img_tiffimages.ifds[1]?

@johnnychen94
Copy link
Member

IFD, with tags:
	Tag(SUBFILETYPE, 0)
	Tag(IMAGEWIDTH, 678)
	Tag(IMAGELENGTH, 647)
	Tag(BITSPERSAMPLE, UInt16[16, 16, 16])
	Tag(PHOTOMETRIC, 2)
	Tag(IMAGEDESCRIPTION, "ImageJ=1.53c
images=...")
	Tag(STRIPOFFSETS, 4186)
	Tag(SAMPLESPERPIXEL, 3)
	Tag(STRIPBYTECOUNTS, 438666)
	Tag(COLORMAP, UInt16[0, 256, 512, 768, 1024, ...])
	Tag(SAMPLEFORMAT, UInt16[1, 1, 1])
	Tag(UNKNOWN(50838), UInt32[20, 48, 768, 768, 768])
	Tag(UNKNOWN(50839), UInt8[73, 74, 73, 74, 114, ...])

@tlnagy
Copy link
Contributor

tlnagy commented Feb 17, 2022

Hmmm. I'll have to look into it more. Looks like TiffImages is detecting that the image is 16bit RGB, but it also has a Colormap Tag which it shouldn't have. It might be that the image has an alternate planar configuration but it's missing that tag so I'm not sure what is going on with it.

What should dimensions should the image have?

@johnnychen94
Copy link
Member

johnnychen94 commented Feb 17, 2022

What should dimensions should the image have?

@DiegoPerezDones perhaps knows more about this. This is what I get from ImageJ, I guess that means 84 3-channel frames of size (678, 647)

image

@tlnagy
Copy link
Contributor

tlnagy commented Feb 17, 2022

Whoa. That's bizarre, the image is claiming 16bits for both red, green, and blue channels, but ImageJ opens it as a 8bit?

This issue is with TiffImages and not with Images.jl and will take some work to figure out.

@johnnychen94
Copy link
Member

close in favor of tlnagy/TiffImages.jl#72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants