UTS Image Prosessing Mif'ad Ikromullah
UTS Image Prosessing Mif'ad Ikromullah
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = PengolahanCitra_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
try
Img = imread(fullfile(pathname,filename));
[~,~,m] = size(Img);
if m == 3
axes(handles.axes1)
imshow(Img)
handles.Img = Img;
guidata(hObject, handles)
end
catch
msgbox('Please insert RGB Image')
end
try
if (popup1 == 1) %Normal
if (popup2 == 1) %Histogram1
if (popup3 == 1) %RGB
Img = handles.Img;
axes(handles.axes1)
cla('reset')
imshow(Img)
R = Img(:,:,1);
G = Img(:,:,2);
B = Img(:,:,3);
axes(handles.axes2)
cla('reset')
h = histogram(R(:),256);
h.FaceColor = [1 0 0];
h.EdgeColor = 'r';
hold on
h = histogram(G(:),256);
h.FaceColor = [0 1 0];
h.EdgeColor = 'g';
h = histogram(B(:),256);
h.FaceColor = [0 0 1];
h.EdgeColor = 'b';
grid on
set(gca,'Xlim',[0 255])
hold off
elseif (popup3 == 2) %Grayscale
Img = handles.Img;
Gray = rgb2gray(Img);
axes(handles.axes1)
cla('reset')
imshow(Gray)
axes(handles.axes2)
cla('reset')
h = histogram(Gray(:),256);
h.FaceColor = [0.5 0.5 0.5];
h.EdgeColor = [0.5 0.5 0.5];
set(gca,'Xlim',[0 255])
grid on
axes(handles.axes1)
cla('reset')
imshow(bw)
axes(handles.axes2)
h = histogram(double(bw(:)),2);
h.FaceColor = [0 0 0];
h.EdgeColor = [0 0 0];
set(gca,'Xlim',[0 1])
grid on
end
else (popup2 == 2) %Histogram2
if (popup3 == 1) %RGB
Img = handles.Img;
axes(handles.axes1)
cla('reset')
imshow(Img)
axes(handles.axes2)
cla('reset')
imhist(Img);
axes(handles.axes2)
cla('reset')
imhist(Gray);
axes(handles.axes2)
cla('reset')
imhist(bw);
end
end
else (popup1 == 2) %Complement
Img = handles.Img;
Img_Comp = imcomplement(Img);
if (popup2 == 1) %Histogram1
if (popup3 == 1) %RGB
axes(handles.axes1)
cla('reset')
imshow(Img_Comp)
R = Img_Comp(:,:,1);
G = Img_Comp(:,:,2);
B = Img_Comp(:,:,3);
axes(handles.axes2)
cla('reset')
h = histogram(R(:),256);
h.FaceColor = [1 0 0];
h.EdgeColor = 'r';
hold on
h = histogram(G(:),256);
h.FaceColor = [0 1 0];
h.EdgeColor = 'g';
h = histogram(B(:),256);
h.FaceColor = [0 0 1];
h.EdgeColor = 'b';
set(gca,'Xlim',[0 255])
grid on
hold off
elseif (popup3 == 2) %Grayscale
Gray_Comp = rgb2gray(Img_Comp);
axes(handles.axes1)
cla('reset')
imshow(Gray_Comp)
axes(handles.axes2)
cla('reset')
h = histogram(Gray_Comp(:),256);
h.FaceColor = [0.5 0.5 0.5];
h.EdgeColor = [0.5 0.5 0.5];
set(gca,'Xlim',[0 255])
grid on
else (popup3 == 3) %Binary
Gray_Comp = handles.Img;
bw_Comp = im2bw(Gray_Comp,graythresh(Gray_Comp));
axes(handles.axes1)
cla('reset')
imshow(bw_Comp)
axes(handles.axes2)
h = histogram(double(bw_Comp(:)),2);
h.FaceColor = [0 0 0];
h.EdgeColor = [0 0 0];
set(gca,'Xlim',[0 1])
grid on
end
else (popup2 == 2) %Histogram2
if (popup3 == 1) %RGB
axes(handles.axes1)
cla('reset')
imshow(Img_Comp)
axes(handles.axes2)
cla('reset')
imhist(Img_Comp);
axes(handles.axes2)
cla('reset')
imhist(Gray_Comp);
axes(handles.axes2)
cla('reset')
imhist(bw_Comp);
end
end
end
catch
msgbox('Please insert RGB Image')
end
Published with MATLAB® R2019b
LAMPIRAN