[問題] 影像及全域變數問題已回收

看板MATLAB作者 (麵包不是熊)時間16年前 (2009/03/21 23:08), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
目前我想用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
文章代碼(AID): #19nGB_k6 (MATLAB)
文章代碼(AID): #19nGB_k6 (MATLAB)