matlab中noholes,Matlab错误不支持的图像数据类型'struct'

目前我正在matlab上进行图像处理项目,我简单地使用网络摄像头捕捉图像,保存图像,使用hough变换处理图像,然后尝试保存图像。当我在转换的图像上使用imwrite函数时,出现此错误:

??? 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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值