Selamat Datang Di Blog Decka

Selamat Datang Di Blog Decka

Selasa, 18 November 2008

Sript_matlab_Grayscale





function varargout = GUIdemo(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUIdemo_OpeningFcn, ...
'gui_OutputFcn', @GUIdemo_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function GUIdemo_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;

guidata(hObject, handles);

image_file = get(handles.inEdit,'String');
if ~isempty(image_file)
im_original=imread(char(image_file));
set(handles.newIm,'HandleVisibility','OFF');
set(handles.orgIm,'HandleVisibility','ON');
axes(handles.orgIm);
image(im_original);
axis equal;
axis tight;
axis off;
set(handles.orgIm,'HandleVisibility','OFF');
end;

function varargout = GUIdemo_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;


function edit3_CreateFcn(hObject, eventdata, handles)
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function inEdit_CreateFcn(hObject, eventdata, handles)
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function inEdit_Callback(hObject, eventdata, handles)
function loadPush_Callback(hObject, eventdata, handles)

image_file = get(handles.inEdit,'String');
if ~isempty(image_file)
im_original=imread(char(image_file));
set(handles.newIm,'HandleVisibility','OFF');
set(handles.orgIm,'HandleVisibility','ON');
axes(handles.orgIm);
image(im_original);
axis equal;
axis tight;
axis off;
set(handles.orgIm,'HandleVisibility','OFF');
end;
function transfCheck_Callback(hObject, eventdata, handles)
function intSlider_CreateFcn(hObject, eventdata, handles)
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function intSlider_Callback(hObject, eventdata, handles)
t = get(handles.intSlider,'value');
set(handles.valText,'String',num2str(t));
function appPush_Callback(hObject, eventdata, handles)
Flag = get(handles.transfCheck,'value');
scale = get(handles.intSlider,'value');
image_file = get(handles.inEdit,'String');
orim=imread(char(image_file));

orim = double(orim);

if Flag == 0

nim = orim*scale;
nim = (nim <=255 ).*nim + (nim>255)*255;
set(handles.newIm,'HandleVisibility','OFF');
set(handles.orgIm,'HandleVisibility','ON');
axes(handles.orgIm);
image(orim/255);
axis equal;
axis tight;
axis off;
set(handles.orgIm,'HandleVisibility','OFF');
set(handles.orgIm,'HandleVisibility','OFF');
set(handles.newIm,'HandleVisibility','ON');
axes(handles.newIm);
m = max(max(max(nim)));
if m>255
t = m;
else t = 255;
end;
image(nim/t);
axis equal;
axis tight;
axis off;
set(handles.newIm,'HandleVisibility','OFF');
else
im = floor((orim(:,:,1)+orim(:,:,2)+orim(:,:,3))/3);
set(handles.newIm,'HandleVisibility','OFF');
set(handles.orgIm,'HandleVisibility','ON');
axes(handles.orgIm);
image(im);
colormap(gray(256));
axis equal;
axis tight;
axis off;
set(handles.orgIm,'HandleVisibility','OFF');

nim = im*scale;
nim = (nim>255)*255+(nim<=255 & nim>0).*nim;
set(handles.newIm,'HandleVisibility','ON');
axes(handles.newIm);
image(nim);
colormap(gray(256));
axis equal;
axis tight;
axis off;
set(handles.newIm,'HandleVisibility','OFF');
end;


function closePush_Callback(hObject, eventdata, handles)
close all;

Tidak ada komentar:

Posting Komentar

Bagaimana Menurut Anda Blog Saya