MATLAB: Image comparison with respect to edges – 2

compareedge detectionimageimage processingMATLAB

I want to compare two pictures with respect to edges.
I have a slit that moves over lens and camera takes pictures for each step on lens.
To detection of starting point of lens, i want to take pictures continuously and use edge detection to compare with old picture until having a picture with edges.
At my last question, i mentioned, the first picture is full of dark. But after many tries, I saw that sometimes some noises can occur. Without using any filter to delete these noises and so without using the command "any()", How can i compare and tell to program if a picture occurs?

Best Answer

This is my interpretation of your question:"How do I find the first valid image which has a slit in it? I cant use any because there could be some noise".
How about sum instead? If the sum of all pixel values is above a certain threshold you could assume that a valid slit was captured.
You could also try variations like using the number of pixels above a threshold value as a trigger condition. [Sean de]'s code and explanation:
Npx_bright = sum(I(:)>80)
The '>' makes every pixel with an intensity larger than 80 one and everything else zero; the (:) turns it into a column vector for summing the 'sum()' adds up all of the ones.