Login  Register

Re: Compare two gray value pictures

Posted by Rasband, Wayne (NIH/NIMH) [E] on Aug 09, 2010; 3:52pm
URL: http://imagej.273.s1.nabble.com/Compare-two-gray-value-pictures-tp3687310p3687319.html

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");