How do I subtract the following two images and determine the number of pixels in a certain section of an image?

8 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Image Analyst
Image Analyst le 2 Fév 2019
Modifié(e) : Image Analyst le 2 Fév 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.
0001 Screenshot.png
  6 commentaires
Image Analyst
Image Analyst le 21 Fév 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.
Jialu Wang
Jialu Wang le 23 Fév 2019
Hi so I've tried subtracting the pink background image with a frame that has the gray moving in, but keep getting something that looks like this. What am I doing wrong? I'm not exactly sure how to apply a median filter--is that the issue? Should I convert to HSV space first?
Also what would a KNN or SVM code look like? Will the colour thresholding code you posted originally still work after I do the image subtraction?
subtract.PNG

Connectez-vous pour commenter.

Plus de réponses (1)

sangeetha N
sangeetha N le 8 Fév 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?

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by