Untitled

mail@pastecode.io avatar
unknown
plain_text
13 days ago
470 B
2
Indexable
Never
% Load the image 
img = imread('ngc6543a.jpg'); % Replace 'peppers.png' with your image 

 
% Convert to grayscale if the image is in color 
if size(img, 3) == 3 
    img = rgb2gray(img); 
end 
 
% Calculate the negative of the image 
negativeImg = 255 - img; 
 
% Display the original image 
subplot(1, 2, 1); 
imshow(img); 
title('Original Image'); 
 
% Display the negative image 
subplot(1, 2, 2); 
imshow(negativeImg); 
title('Negative Image'); 
Leave a Comment