This is the example from the ImageDifference manual page:
In[]:=
i1=
;i2=
;
Check the image dimensions:
In[]:=
Dimensions[ImageData[i1]]Dimensions[ImageData[i2]]
Out[]=
{257,384,3}
Out[]=
{256,385,3}
Note the slight difference between the two. i1 has one more row than i2, but i2 has an extra column.
For the moment, let's manually make them both the same size.
For the moment, let's manually make them both the same size.
In[]:=
i1C=ImageTake[i1,{1,256},All];i2C=ImageTake[i2,All,{1,384}];
ImageDifference Stuff
ImageDifference Stuff
ImageAlign Stuff
ImageAlign Stuff
Next, want to perform image registration on the two images automatically. From what I understand, this can be accomplished using ImageAlign. So, let's test this…
Output i2 with the dimensions of i1:
Output i2 with the dimensions of i1:
In[]:=
ImageAlign[i1,i2]ImageAlign[i1,i2]//ImageData//Dimensions
Out[]=
Out[]=
{257,384,4}
Output i1 with the dimensions of i2:
In[]:=
ImageAlign[i2,i1]ImageAlign[i2,i1]//ImageData//Dimensions
Out[]=
Out[]=
{256,385,4}
This appears to work except for the third dimension: 4 versus 3 in both cases. However, this seems to cause a problem since using this result in ImageDifference does not yield the same results as achieved above. I'm guessing it has something to do with that differing third dimension.
In[]:=
ImageAlign[i2,i1]
Out[]=
Attempt to difference i2 with the image registered i1 (ImageAlign[i2, i1]).
In[]:=
ImageDifference[ImageAlign[i2,i1],i2]
Out[]=
This is NOT the expected result!
Was expecting to see the one pill. Instead, I'm getting the extra column present in i2.
I checked the Attributes of the ImageDifference and ImageAlign commands, but neither seems to Hold, or delay their evaluations…
However, this is interesting. If I expose the image data, them generate the image from that the result is what I anticipated. I don't understand why this works while the ImageDifference on the ImageAlign doesn't.
Was expecting to see the one pill. Instead, I'm getting the extra column present in i2.
I checked the Attributes of the ImageDifference and ImageAlign commands, but neither seems to Hold, or delay their evaluations…
However, this is interesting. If I expose the image data, them generate the image from that the result is what I anticipated. I don't understand why this works while the ImageDifference on the ImageAlign doesn't.
In[]:=
ImageData[ImageDifference[ImageAlign[i2,i1],i2]]//Image
Out[]=