Antarmuka GUI MATLAB ini dapat dipakai untuk laboratorium sinyal bagi mahasiswa dan untuk menunjang penelitian bagi para peneliti. Anda bisa memesannya pada form pemesanan di bawah ini.
KODE UNTUK SALAH SATU EVENT CALLBACK:
% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) g=getimage(handles.axes1); citra_semula= getimage(handles.axes6); % B-Spline I 2x inputI = g; [r,c] = size(g); vert = 2; hor = 2; rn = floor(hor*r); cn = floor(vert*c); im_zoom = zeros(rn,cn); for i = 1:rn; x1 = cast(floor(i/hor),'uint32'); x2 = cast(ceil(i/hor),'uint32'); if x1 == 0 x1 = 1; end x = rem(i/hor,1); for j = 1:cn; y1 = cast(floor(j/vert),'uint32'); y2 = cast(ceil(j/vert),'uint32'); if y1 == 0 y1 = 1; end ctl = inputI(x1,y1); cbl = inputI(x2,y1); ctr = inputI(x1,y2); cbr = inputI(x2,y2); y = rem(j/vert,1); tr = (ctr*y)+(ctl*(1-y)); br = (cbr*y)+(cbl*(1-y)); im_zoom(i,j,:) = (br*x)+(tr*(1-x)); end end image_zoom = cast(im_zoom,'uint8'); error = citra_semula - (image_zoom); MSE2 = sum(sum(error .* error)) / (r * c); set(handles.edit5, 'String', num2str(MSE2)); % Pembesaran Bicubic 2x vert = 2; hor = 2; inputI = g; [r c] = size(inputI); rn = floor(hor*r); cn = floor(vert*c); %s = zoom; im_zoom = cast(zeros(rn,cn),'uint8'); im_pad = zeros(r+4,c+4); im_pad(2:r+1,2:c+1) = inputI; im_pad = cast(im_pad,'double'); for m = 1:rn x1 = ceil(m/hor); x2 = x1+1; x3 = x2+1; p = cast(x1,'uint16'); if(hor>1) m1 = ceil(hor*(x1-1)); m2 = ceil(hor*(x1)); m3 = ceil(hor*(x2)); m4 = ceil(hor*(x3)); else m1 = (hor*(x1-1)); m2 = (hor*(x1)); m3 = (hor*(x2)); m4 = (hor*(x3)); end X = [ (m-m2)*(m-m3)*(m-m4)/((m1-m2)*(m1-m3)*(m1-m4)) ... (m-m1)*(m-m3)*(m-m4)/((m2-m1)*(m2-m3)*(m2-m4)) ... (m-m1)*(m-m2)*(m-m4)/((m3-m1)*(m3-m2)*(m3-m4)) ... (m-m1)*(m-m2)*(m-m3)/((m4-m1)*(m4-m2)*(m4-m3))]; for n = 1:cn y1 = ceil(n/vert); y2 = y1+1; y3 = y2+1; if (vert>1) n1 = ceil(vert*(y1-1)); n2 = ceil(vert*(y1)); n3 = ceil(vert*(y2)); n4 = ceil(vert*(y3)); else n1 = (vert*(y1-1)); n2 = (vert*(y1)); n3 = (vert*(y2)); n4 = (vert*(y3)); end Y = [ (n-n2)*(n-n3)*(n-n4)/((n1-n2)*(n1-n3)*(n1-n4));... (n-n1)*(n-n3)*(n-n4)/((n2-n1)*(n2-n3)*(n2-n4));... (n-n1)*(n-n2)*(n-n4)/((n3-n1)*(n3-n2)*(n3-n4));... (n-n1)*(n-n2)*(n-n3)/((n4-n1)*(n4-n2)*(n4-n3))]; q = cast(y1,'uint16'); sample = im_pad(p:p+3,q:q+3,:); im_zoom(m,n,1) = X*sample(:,:,1)*Y; end end im_zoom = cast(im_zoom,'uint8'); error = citra_semula - (im_zoom); MSE3 = sum(sum(error .* error)) / (r * c); set(handles.edit9, 'String', num2str(MSE3)); % Pembesaran B-Spline II 2x zoom = 2; inputI = g; [r c] = size(inputI); img = cast(inputI,'double'); faktor = 1/zoom; x = 1:c; xx = 1:faktor:(c+1-faktor); for i = 1:r cs(i,:) = [spline(x,[0 img(i,:) 0],xx),img(i,end)]; end y = 1:r; yy = 1:faktor:(r+1-faktor); for i = 1:(zoom*c) us(:,i) = (spline(y,[0 cs(:,i)' 0],yy))'; end imZoom = cast(us,'uint8'); error = citra_semula - (imZoom); MSE4 = sum(sum(error .* error)) / (r * c); set(handles.edit13, 'String', num2str(MSE4)); figure, h1=subplot(2,3,1), imshow(citra_semula); title('Citra 512 x 512'); h2=subplot(2,3,2), imshow(g); title('Citra Uji 256 x 256'); h3=subplot(2,3,3), imshow(image_zoom); title('Pembesaran B-Spline I 2x'); h4=subplot(2,3,4), imshow(im_zoom); title('Pembesaran Bicubic 2x'); h5=subplot(2,3,5), imshow(imZoom); title('Pembesaran B-Spline II 2x'); linkaxes([h1,h2,h3,h4,h5])
No comments:
Post a Comment