[問題] 影像及全域變數問題已回收
目前我想用GUI寫
按pushbutton1 讀取圖片
按pushbutton2 利用副程式 處理之後再顯示出來
可是會出現 ??? Index exceeds matrix dimensions.
以下是簡短的程式
%pushbutton1
function pushbutton1_Callback(hObject, eventdata, handles)
global img;
img = OPEN_FILE() ;
imshow(img)
%
%pushbutton2
function pushbutton2_Callback(hObject, eventdata, handles)
global img;
meisob(img);
%
%副程式meisob
function t=meisob(img)
figure;
m=img;
imshow(m) ; % Display the original picture
r=m(:,:,1); %extract the red color
g=m(:,:,2); %extract the green color
b=m(:,:,3); %extract the blue
hx =[ -1 -2 -1; 0 0 0; 1 2 1];
hy =[ -1 0 1; -2 0 2; -1 0 1];
xr=filter2(hx,r);
xg=filter2(hx,g);
xb=filter2(hx,b);
yr=filter2(hy,r);
yg=filter2(hy,g);
yb=filter2(hy,b);
t1(:,:,1)=xr+yr;
t1(:,:,2)=xg+yg;
t1(:,:,3)=xb+yb;
t=uint8(t1);
figure;
imshow(t);
title('sobel濾波')
%
至於OPEN_FILE的程式應該是沒有錯誤的
所以不知道我的global這樣寫有沒有錯誤呢?
新手上路 請各位大大幫忙 感激不盡!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 121.254.120.56
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章