0
目前我正在matlab上進行圖像處理項目,我簡單地捕捉圖像與我的攝像頭,保存它,使用hough變換處理圖像,然後嘗試保存它。當我使用imwrite功能轉換後的圖片上我得到這個錯誤:Matlab error不支持的圖像數據類型'結構'
??? Error using ==> imwrite>validateSizes at 596
Unsupported image datatype 'struct'.
Error in ==> imwrite at 422
validateSizes(data);
Error in ==> findLine at 48
imwrite(tapes,fullImageFileName2);
我真的不知道什麼是怎麼回事,但我用的是imwrite當圖像被首先採取的攝像頭,並且不保存錯誤。它是我第二次嘗試保存圖像,這是我得到此錯誤的轉換圖像。任何任何想法?
這是到目前爲止我的代碼:
vidobj = videoinput('winvideo');
preview(vidobj);
pause(10);
snapshot = getsnapshot(vidobj);
fullImageFileName = fullfile(pwd, 'line.jpg');
imwrite(snapshot,fullImageFileName);
imagesc(snapshot);
imshow(snapshot);
%Load image
tape = imread('C:\Users\Mustafa\Documents\MATLAB\line.jpg');
%Displays the valid values for the Image Processing
iptsetpref ImshowBorder tight
imshow(tape)
%Segment by thresh holding
thresh1 = 100;
tapes = im2bw(tape, thresh1/255);
imshow(tapes)
%Clean up image
%Morphology to assist segmentation
tapes = bwareaopen(tapes,100);%area under 100 pixels
imshow(tapes)
%Clear objects touching the line
%suppresses structures that are lighter than their surroundings and that are connected to the image border.
%(In other words, use this function to clear the image border.)
%tapes = imclearborder(tapes, 26);
%imshow(tapes)
%Find tape
%Find all connected regions
[B,L] = bwboundaries(tapes, 'noholes');
numRegions = max(L(:));
imshow(label2rgb(L))
%Hough transform
[H, theta, rho] = hough(tapes);
peaks = houghpeaks(H, 2);
tapes = houghlines(tapes, theta, rho, peaks, 'FillGap', 50, 'MinLength', 30);
fullImageFileName2 = fullfile(pwd, 'linedetect.png');
imwrite(tapes,fullImageFileName2,'BitDepth',16);
我們需要更多信息,你可以輸入'whos tapes'並報告它說的內容。 (它看起來像'tapes'是一個結構,所以也可以很好地展示你如何創建'tapes'。) – 2011-04-29 18:52:29
我已經更新了上面的代碼, – user427641 2011-04-29 18:58:20
tapes = houghlines(tapes,theta,rho,peaks,'FillGap' ,50,'MinLength',30);輸入'whos磁帶'後輸入 – user427641 2011-04-29 18:58:30