How to add and subtract two color images in matlab?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sajina Rose
le 31 Jan 2020
Commenté : Sajina Rose
le 1 Fév 2020
I-G(I);
where I=original image and G(I)=Gaussian filtered version of I.
2 commentaires
Rik
le 31 Jan 2020
Using just the normal symbols will result in an element-wise addition or subtraction. That could cause issues with underflow and overflow if you are using an integer data type, and the result might not be what you mean.
What is your question? What have you tried? How did it fail to match your desired result?
Réponse acceptée
Subhadeep Koley
le 1 Fév 2020
Hi, Sajina the function imsubtract expects two real, nonsparse, numeric or logical image. Threfore the below syntax is not right.
z = imsubtract(double(X)-double(Y));
Try the code below.
% Read your image here
X = imread('peppers.png');
figure; imshow(X, []); title('Original Color Image');
% Gaussian Filtering
sigma = 5; % Standard deviation of the kernel
Y = imgaussfilt(X, sigma);
figure; imshow(Y, []); title('Gaussian Filtered Image');
Z = imsubtract(X, Y);
N = imadjust(Z, stretchlim(Z));
figure,imshow(N, []), title('Histogram Stretched Subtracted Image');
Hope this helps!
4 commentaires
Subhadeep Koley
le 1 Fév 2020
% Read your image here
X = imread('peppers.png');
figure; imshow(X, []); title('Original Color Image');
% Gaussian Filtering
sigma = 5; % Standard deviation of the kernel
Y = imgaussfilt(X, sigma);
figure; imshow(Y, []); title('Gaussian Filtered Image');
Z = imsubtract(X, Y);
N = imadjust(Z, stretchlim(Z));
figure,imshow(N, []), title('Histogram Stretched Subtracted Image');
U = (imadd(X, N)) / 2;
figure,imshow(U, []); title('Unsharp Masked Image');
XSharp = imsharpen(X, 'Radius', 1.5, 'Amount', 2);
figure,imshow(XSharp, []), title('Unsharp Masked Image');
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!