How do I subtract the following two images and determine the number of pixels in a certain section of an image?
2 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Image Analyst
on 2 Feb 2019
Edited: Image Analyst
on 2 Feb 2019
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.
6 Comments
Image Analyst
on 21 Feb 2019
No, don't subtract them after they've been binarized. If you have a good baseline/reference color or gray scale image, subtract that from each frame before doing color segmentation to form the binary image mask of the "test" frame.
More Answers (1)
sangeetha N
on 8 Feb 2019
What to do if it was a video file? How to get the subtracted image?
If the objects are stationary,then after subtracting the input image and adaptive background image, I am getting number of objects as zero.How to solve this problem?
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!