grey image color restoration after image subtraction

2 vues (au cours des 30 derniers jours)
Yiu On LEUNG
Yiu On LEUNG le 2 Juil 2022
Commenté : Yiu On LEUNG le 4 Juil 2022
After my image subtraction with Matlab, the subtracted image has some black area formed due to the subtraction. Is there any ways that I can restore the black region to its original color?
I have tried to adjust the brightness or intensity but they did not work.

Réponse acceptée

Image Analyst
Image Analyst le 2 Juil 2022
Are your images color or grayscale?
To avoid clipping to 0, like will happen if you subtract a larger uint8 number from a smaller one, you can cast to double
subtractionImage = double(testImage) - double(backgroundImage);
imshow(subtractionImage, []);
Why are you getting 0? Is it because your test image is the same intensity as your background image there? Or your background image is brighter than your test image?
Why are you doing subtraction? Is it to flatten the background to correct for lighting non-uniformities and lens shading? If so you're probably better off doing a background division rather than a background subtraction.
Can you upload your test image and background image?
  2 commentaires
Image Analyst
Image Analyst le 4 Juil 2022
@Yiu On LEUNG, are you still there?
Yiu On LEUNG
Yiu On LEUNG le 4 Juil 2022
Thank you for the reply. After carefully considering your advices, I realised that it maybe caused by the contrast problem, so I performed some image prepoecessing and solved the issue.

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 2 Juil 2022
mask = repmat(all(Subtracted == 0, 3), 1, 1, 3);
Subtracted(mask) = Original(mask);

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by