Problem with ImageJ and Matlab image analysis

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with ImageJ and Matlab image analysis

Abdulelah
Hi,

I'm working on my research and I require to do some gray value measurements
for some of the images.
I import the same images in ImageJ and Matlab and did the measurement for
the exact same image with exact same coordinate (x, y, z) for a specific
pixel but the reading in both of softwares were different. I tried it for a
couple of points (pixels) in different coordinates but had the same issue.

Can anyone explain why and help me fixing that problem?

Thank you.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ImageJ and Matlab image analysis

Alex-2
Can you give an example of the values from both imageJ and MATLAB?  They may just be normalized differently. 
Alex


Sent from Yahoo Mail for iPhone


On Friday, February 2, 2018, 3:38 PM, Abdulelah Aldahlawi <[hidden email]> wrote:

Hi,

I'm working on my research and I require to do some gray value measurements
for some of the images.
I import the same images in ImageJ and Matlab and did the measurement for
the exact same image with exact same coordinate (x, y, z) for a specific
pixel but the reading in both of softwares were different. I tried it for a
couple of points (pixels) in different coordinates but had the same issue.

Can anyone explain why and help me fixing that problem?

Thank you.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ImageJ and Matlab image analysis

Ziqiang Huang
It’s quite possible the horizontal and vertical dimensions are represented differently in Fiji and Matlab. You can try to transpose the 1st and 2nd dimension of the array you got from imread in matlab, and see if that gives you the match (z axis doesn’t matter)

Good luck

> On 3 Feb 2018, at 00:43, Alex <[hidden email]> wrote:
>
> Can you give an example of the values from both imageJ and MATLAB?  They may just be normalized differently.
> Alex
>
>
> Sent from Yahoo Mail for iPhone
>
>
> On Friday, February 2, 2018, 3:38 PM, Abdulelah Aldahlawi <[hidden email]> wrote:
>
> Hi,
>
> I'm working on my research and I require to do some gray value measurements
> for some of the images.
> I import the same images in ImageJ and Matlab and did the measurement for
> the exact same image with exact same coordinate (x, y, z) for a specific
> pixel but the reading in both of softwares were different. I tried it for a
> couple of points (pixels) in different coordinates but had the same issue.
>
> Can anyone explain why and help me fixing that problem?
>
> Thank you.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ImageJ and Matlab image analysis

Abdulelah
In reply to this post by Abdulelah
Sorry for the delayed response

As Alex request, here a full details and example of points I did before:


I have a data set (CT scan images) of 430 slices. I import it to imageJ and also have it open in Matlab:

Examples:

Point 1

on ImageJ

x=180, y=424, z=243 (Slice # 244, as it shown in the top left corner on the window of the image)

on Matlab
Y(181, 425, 244), The reason I add 1 to all value because x, y, z starts from zero in imageJ but from 1 in Matlab as it should have a real positive value. Also, will explain what I also did be the end.

Pixel size= 1

Matlab ans= -214,        ImageJ Value= -416(584)     Difference= 202

---------------------------------------------------------------------------

Point 2

on ImageJ x=358, y=509, z=261     (Slice 262)


on Matlab Y(359, 510, 262)
 
Pixel size= 1


ans= -154,        ImageJ value= -127(873)     Difference= 30



---------------------------------------------------------------------------

Point 3

on ImageJ  x=390, y=360, z=261    (Slice 274)

on Matlab Y(391, 361, 274)
 
Pixel size= 1

Y ans= -398,        ImageJ value= -507(493)     Difference= 109

----------------------------------------------------------------------------

When I saw there was some difference in the grey values between the 2 softwares I tried in ImageJ to change the x or y or even the slice (all around the point I measured before and even one to two slices up and one to two slices down) just to get the same number (ans) I have in Matlab but unfortunately I didn't find any match.

Thank you.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ImageJ and Matlab image analysis

Abdulelah
In reply to this post by Abdulelah
I will give it a try. Thank you Ziqiang.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ImageJ and Matlab image analysis

Abdulelah
In reply to this post by Abdulelah
Hi,

First, thank you all for your thoughts and suggestions. I truly appreciate it and it help by way or another.


Second, thanks to God I finally been able to figure what or where to problem is.

As someone of you said that the orientation (or projection) of the image is different from ImageJ to Matlab, it is true. It seems to be Matlab switch the x, y whenever you give it the order to read it and give you the answer to any point directly. However, it is not when it shows it in a figure. Will give an example to better understand what i'm saying:

So, if I opened my data set in imageJ and Matlab (let's say I have a stack of images 1-100). In ImageJ if i scroll over to any of slice I want then select a point or move the cruiser to certain point (I usually zoom in till I can see each pixel to accurately select only one pixel to check for it's gray value)  ImageJ will show you the x (represents the row, y (represents the column), z (represents the slice) immediately below the tool bar without even clicking on the point.
x= 274, y= 361, z= 44, Value= 14 (In ImageJ these coordinate they all start from 0)

Now, if I order Matlab to give me the exact same point value supposly  I need to type it like this:
Y(275, 362, 45) I add one all over x, y, z as Matlab can only read a true positive and all start from 1
ans = 77

however, if you type it the other way (y then x then z):
Y(362, 275, 45)
ans = 14 (it will show the same value for ImageJ

Last, if I give the Matlab an order to open a figure (e.g 44) and put the coordinate for that figure to same as the ImageJ (I mean x then y orientation)
Figure(44)
imagesc(275, 362, 45) it will show that exact pixel only or you can type (:, :, z) it will show the whole image
Then you can search and read that point (275, 362) and it will give the same value = 14




To make it short, if you wish to have the same reading between ImageJ and Matlab. Whenever you give the order to Matlab just flip row (x) number to column (y) and vice versa and you will get the same value.  

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Problem with ImageJ and Matlab image analysis

Abdulelah
In reply to this post by Abdulelah
Just forgot to metion one thing (beside I'm sorry for my spelling mistakes)

ImageJ usually read the image in mm (the numbers shown will be in 2 digit and start from 0.25, e.g. x = 75.25, y = 65.50, z= 34)  but Matlab read it in pixels so make sure you change that in ImageJ whenever you open a new image by:

shortcut press: ctrl+shift+P       or
from the tool bar in ImageJ click on image --> properties:
Change the unit of length from mm to pixel
then for all pixel width, pixel height and voxel depth change it to 1.0




--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html