Image Processing Toolbox: Subtracting 2 images
Show older comments
Hi everyone! I am working with an image of a cone. Attached:

As you can see, there is a lot of imperfections and I will like to remove them and leave only the black outline of the cone. My first thought was to take the same picture, but without a cone and the substract them. I attach the second image without the cone.

Nevertheless, the operation isnt working as I will expect. The results of the operation are the following, each accounting for different substractions.

In this image imperfections are still present.

And in this image I tried increasing the brightness but didnt work.
Am I thinking the method wrong? Or is there any other better method to process this images?
Thank you in advance!
Accepted Answer
More Answers (1)
Image Analyst
on 21 Apr 2021
What I'd do is to make a template of the bright spot without the cone. Then determine the means and scale them, then subtract.
% Get the mean of each image.
mean1 = mean(refimage(mask))
mean2 = mean(testImage(mask));
% Scale test image's mean to be the same as the reference image's mean.
testImage = double(testImage) * mean1 / mean2;
% Cast it back to the same image type as refImage.
testImage = cast(testImage, 'like', refimage);
% Now subtract.
subtractionImage = imabsdiff(refImage, testImage);
Now they should subtract much closer to zero than with what you did.
1 Comment
Urbano Alfonso Medina Martinez
on 21 Apr 2021
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!