Currently I am working on matlab for an image processing project and I am simpley capturing an image with my webcam, saving it, processing the image using the hough transform and then trying to save it. When I use the imwrite function on the transformed image I get this 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);
I dont really know whats going on here but I use the imwrite function when the image is first taken by the webcam and That saves with no errors. Its the second time I try to save an image, which is the transformed image I get this error. Anyone any ideas?
This is my code so far:
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 tapesand report what it says. (It looks liketapesis a struct, so would also be good to show how you createstapes.)