MATLAB: How to subtract the following two images and determine the number of pixels in a certain section of an image

edge detectionimage arithmeticimage processingImage Processing Toolboximage segmentationimage subtraction

pdms1.jpgpdms2.jpg
How would I subtract the following two images of the same size? My goal is to subtract and remove the purple section so I can determine the number of pixels in the gray section on the lower left (below the black line). My problem is that the purple section in both images aren't exactly the same, since they are different frames of a video. Would it be easier to just focus on the second image using some image segmenting or edge detection technique? Please help me out.

Best Answer

Definitely not edge detection. What I'd do is use the Color Thresholder App on the Apps tab of the tool ribbon and segment in HSV color space. Then export the function to create a mask. Then you can use bwareafilt() to extract the largest blob or blobs of certain sizes.
[EDIT]
OK, since a lot of time has gone by and you still haven't responded, I'm assuming you couldn't quite get it. So I'm attaching a script that gives you the area.
area = 35389 pixels
Adapt as needed.
0001 Screenshot.png