What is Image shading in MATLAB? (original) (raw)

`% MATLAB code that will work for various objects and images. function sharpened_image global filename GFG; scz=get(0,'ScreenSize'); figure('Position',[round(scz(1,3)/8) round(scz(1,4)/9) 400 500],'MenuBar','NumberTitle','off','Name', 'Pencil sketch Application','Resize','off'); axes('Position',[0 0 .8 1],'atick',[],'btick',[]); shade=uicontrol('Style','slider','Position', [400,310 100 20],'Max',1 ,'Min',0.01,' Value',0.56,'Callback',@draw); thresh=uicontrol('Style','slider','Position', [400,370 100 20],'Max',255,'Min',0, 'Value',30,'Callback',@draw); directory=dir('*.jpg'); files={directory.name}; tval=uicontrol('style','text','Position', [400,340 700 20]','Thresh :'); line=uicontrol('style','text','Position', [400,395 800 20]','String','Line :'); uicontrol('style','text','Position', [400,455 100 200]','Filename:'); uicontrol('Style','popupmenu','position', [400 420 180 30],'Value',1,'String', files,'Callback',@displayfile);

function file_display(obj,~)
    ptr=get(obj,'value');
    filename=char(files(ptr));
    X1=imread(filename);                      
    imshow(X1);
end
function draw(~,~)
    sh=get(shade,'Value');
    thr=get(thresh,'Value');
    thval=strcat('Thresh :', num2str(sh));
    set(tval,'String',thval);
   
    lineval=strcat('Line :', num2str(thr));
    set(line,'String',lineval);
   if(~isempty(B1))
    X1=imread(filename);
    B=rgb2gray(X1);

% The Edge of the image is detected using % the sobel edge detection method. C3=edge(B,'sobel','VERTICAL'); C2=edge(B,'sobel','HORIZONTAL'); C=uint8(C3.*C2);

% The image is sharpened by subtracting the blur image. F1=uint8(imfilter(B,fspecial('unsharp')/sh));

% The blending of the edge and the filtered image is done.

for m=1:size(F1,1) for n=1:size(F1,2) if(C(m,n)==0) F1(m,n)=B(m,n)-thr; end end end imshow(F1); end end end

`