Hello dear community,
I have two gray value pictures which I want to compare with each other. My idea was to subtract each gray value from each pixel and to compare them! If they are not the same, it would be good to mark them red! Is that possible? I do not have much experience with imagej and in writing macros. I would be very pleased if anyone could help me! Thank you in advance!!!!!!! |
Dear Anna Klaus!
>Hello dear community, > >I have two gray value pictures which I want to compare with each other. My >idea was to subtract each gray value from each pixel and to compare them! If >they are not the same, it would be good to mark them red! >Is that possible? You may proceed like this but... What you get is a resulting difference image, well sort of. Is this really what you like to see? Most often, when comparing signals one likes to have a single number that tells one how similar two signals are. One possibility for such a coefficient is the sum of the absolute values or of teh squared values of the the difference of the signals or images. This however is a measure of dis-similarity or distance. If you take the square of the difference image you may take the square root of the coefficient which is the known Euclidian distance of the two signals. A measure of similarity is the correlation coefficient which, in its most basic form, is the sum of the product of the two signals. However, for several reasons, it is advisable to use the normalized correlation coefficient or perhaps the normalized covariance that in mathematical statistics is called correlation (cf. textbook of statistics). (Terms are a bit puzzling in this field... In any case if you compare two signals, make sure that they are registered, i.e. that the are not transformed with respect to each other (shifted, rotated etc.) >I do not have much experience with imagej and in writing macros. I would be >very pleased if anyone could help me! Thank you in advance!!!!!!! HTH -- Herbie ------------------------ <http://www.gluender.de> |
Hello Gluender,
Thank yor for your quick answer! I think in my case it would be the best to compare each pixelvalue with each other...! The mean value would not give me the information I want! i try to solve my problem in ImageJ or in Matlab...I do not know which one would be easier, ....but I also do not know how to tell the programm to solve my problem:(! |
In reply to this post by Gluender-4
Hello Gluender,
Thank yor for your quick answer! I think in my case it would be the best to compare each pixelvalue with each other...! The mean value would not give me the information I want! i try to solve my problem in ImageJ or in Matlab...I do not know which one would be easier, ....but I also do not know how to tell the programm to solve my problem:(! |
Dear Anna Klaus!
>Hello Gluender, > >Thank yor for your quick answer! >I think in my case it would be the best to compare each pixelvalue with each >other...! The mean value would not give me the information I want! >i try to solve my problem in ImageJ or in Matlab...I do not know which one >would be easier, ....but I also do not know how to tell the programm to >solve my problem:(! Here we go: I assume that you like to compare two 8bit (monochromatic) images. 1. Open both images in ImageJ 2. From the "Process" menu select item "Image Calculator" 3. Select the proper images for Image1 and 2 and as Operation "Subtract" 4. Make sure the following check boxes are both checked 5. Click OK and you will get a new image. 6. Make sure the new image is in the foreground 7. From the "Image" menu select item "Adjust > Threshold" 8. In the opening dialog there are two pop-up menus. Set them to "Default" and "Red" 9. Click the "Set" button 10. Enter -255 for the "Lower Threshold Level" and 0 for the "Upper Threshold Level" 11. Click OK and close the threshold dialog. 12. Make the Result window with the negative values marked in red the frontmnost window. 13. From the "Image" menu select item "Type > RGB Color" 14. Save the result window. There are other ways to perform the task, e.g. by using a suitable LUT. HTH -- Herbie ------------------------ <http://www.gluender.de> |
In reply to this post by AnnaKlaus
On Aug 9, 2010, at 7:47 AM, AnnaKlaus wrote:
> Hello dear community, > > I have two gray value pictures which I want to compare with each other. My > idea was to subtract each gray value from each pixel and to compare them! If > they are not the same, it would be good to mark them red! > Is that possible? > I do not have much experience with imagej and in writing macros. I would be > very pleased if anyone could help me! Thank you in advance!!!!!!! Here is a macro that demonstrates how to do this. It opens the Boats sample image, duplicates it, erases the two windows in the lighthouse, finds the pixels the differ using the image calculator, uses thresholding to highlight the differences, converts the threshold into a selection, transfers the selection to the first images, and converts it into a red overlay. -wayne run("Close All"); run("Boats (356K)"); run("Duplicate...", "title=missing-windows"); setColor(160); fillRect(201, 258, 5, 17); fillRect(201, 284, 5, 17); imageCalculator("Difference create", 1, 2); setThreshold(1, 255); run("Create Selection"); close; selectImage(1); run("Restore Selection"); run("Add Selection...", "fill=red"); run("Select None"); |
In reply to this post by Gluender-4
Thank you very much!!!!!
This helps me really a lot! But it is still not perfect. If it does not make you too much work, would you please also explain me the other variants! Thanks again!!!!!!!!! |
Dear Anna Klaus!
>Thank you very much!!!!! >This helps me really a lot! But it is still not perfect. If it does not make >you too much work, would you please also explain me the other variants! >Thanks again!!!!!!!!! Now, could you please be more specific: What do you mean by "But it is still not perfect" for you? What I've explained in detail does what you've originally decribed but perhaps your description wasn't to the point. HTH -- Herbie ------------------------ <http://www.gluender.de> |
I am sorry, I do not wanted to seem unthankful! Your description was perfect. My problem is...that there are really very thin lines on the pictures and I want so see if they are removed after an experiment. And if I do your process not only the removed lines are in red, but also a main part of the background, and I cannot distinguish between background and line........aaaah, it is very difficult to explain! Mmmh, probably my whole idea is wrong but I really do not know how to do it better!
Again thank you very mucg for your help! |
Hi.
May be this macro can do a job for you. This is just recorded steps. For you, important are the second and third part of the macro. //1) open sample image and simulate thin stripes run("Bridge (174K)"); run("Duplicate...", "title=bridge-1.gif"); newImage("lines", "8-bit Black", 512, 512, 1); makeLine(65, 80, 445, 80); setForegroundColor(128, 128, 128); // here you can lower or increase (0-255) the intensity of the stripe! try 5,5,5 and check Result of bridge.gif run("Draw"); imageCalculator("OR", "bridge-1.gif","lines"); selectWindow("lines"); close(); selectWindow("bridge-1.gif"); run("Add Specified Noise...", "standard=2"); //specific noise simulate a difference between two shots of the same place in experiment due to the noise //2) comparison of two similar images.... imageCalculator("Difference create", "bridge.gif","bridge-1.gif"); selectWindow("Result of bridge.gif"); run("Enhance Contrast", "saturated=0.35"); //3) make RGB image with line marked with red color. run("Options...", "iterations=1 count=1 black edm=Overwrite"); setAutoThreshold("Yen dark"); run("Convert to Mask"); run("Red"); selectWindow("bridge-1.gif"); run("RGB Color"); imageCalculator("Add create", "bridge-1.gif","Result of bridge.gif"); Best wishes. Ondrej Sebesta Dne 9.8.2010 19:02, AnnaKlaus napsal(a): > I am sorry, I do not wanted to seem unthankful! Your description was perfect. > My problem is...that there are really very thin lines on the pictures and I > want so see if they are removed after an experiment. And if I do your > process not only the removed lines are in red, but also a main part of the > background, and I cannot distinguish between background and > line........aaaah, it is very difficult to explain! Mmmh, probably my whole > idea is wrong but I really do not know how to do it better! > Again thank you very mucg for your help! > > > > Prichozi zprava neobsahuje viry. > Zkontrolovano AVG - www.avg.cz > Verze: 8.5.441 / Virova baze: 271.1.1/3061 - Datum vydani: 08/09/10 18:35:00 > -- ------------------------------------------ Mgr. Ondřej Šebesta Laboratory of Confocal and Fluorescence Microscopy Faculty of Science, Charles University in Prague Vinicna 7 128 44 Prague Czech Republic Phone: +420 2 2195 1943 e-mail: [hidden email] |
Free forum by Nabble | Edit this page |