What is the data type of the pixels? If it is uint8, as would not be uncommon
for images, then you cannot represent a negative value with that data class,
so to subtract the values you would first have to convert them to int16 or
similar.
Thank you for your reply,
Yes, I was using uint8, I changed it to
" subframe=int16(img(24).cdata)-int16(img(1).cdata); "
However How can I convert back them to image so that i can find the middle point of the object ?
Post your images somewhere (such as http://drop.io) so we can see.
Post your two frames and the subtracted one if possible (you might
have to scale it to 0-255 to save it in a standard format such as png
or tif).
Hey, thank you for your reply
I am not working on with direct images, I am loading them from .avi file. the avi file is the same like the png files " http://drop.io/sjfxl0g ". Black circle is moving . I need to detect the motion. I subtract them then find the edges, so that I can compute the middle points of the objects in one frame.
[r,c,v]=find(p>0.1);
r=mean(r);
c=mean(c);
subplot(2,2,1);imshow(p)
hold on
plot(c,r,'.')
This code works for one object.