how to inverse the output image to show image like sketch

4 views (last 30 days)
clc;
clear all;
close all;
Im = imread('sketch.jpg');
Im =double(rgb2gray(Im));
X = double([-1 0 1;-2 0 2;-1 0 1]);
X=rot90(X,2);
Y = double([-1 -2 -1; 0 0 0; 1 2 1]);
Y=rot90(Y,2);
I= Im;
[r,c,z]=size(I);
Fx = zeros(r,c);
Fy = zeros(r,c);
I = padarray(I,[1 1]);
for i=2:r-1
for j=2:c-1
Fx(i,j)=sum(sum(X.*I(i-1:i+1,j-1:j+1)));
Fy(i,j)=sum(sum(Y.*I(i-1:i+1,j-1:j+1)));
end
end
Im=uint8(Im);
FMag=mat2gray(sqrt(Fx.^2+Fy.^2));
im1=FMag;
imshow(im1)

Answers (1)

Image Analyst
Image Analyst on 6 Aug 2020
To invert the image subtract from 1:
FMag = 1 - FMag;

Categories

Find more on Convert Image Type in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!