フィルターのクリア

how to fix Attempt to grow array along ambiguous dimension-Error?

2 ビュー (過去 30 日間)
ezhil K
ezhil K 2019 年 2 月 6 日
コメント済み: KSSV 2019 年 2 月 6 日
I am trying to draw rectangle around the region where there are only the characters and numbers.But I'm getting error.I have attached the code and the error.please help mein rectifying it.
Error is:
Attempt to grow array along ambiguous dimension.
Error in tes (line 33)
redChan(perim) = 255;test3.png
% Clear all varibles and close all windows
clear all;
close all;
% Read in image
imorig = imread('test3.png');
% Threshold and invert
im = ~im2bw(imorig);
% Find bounding boxes of all characters
s = regionprops(im, 'BoundingBox');
bbox = round(reshape([s.BoundingBox], 4, []).');
% Create a blank image and for each box, fill in with white
outImg = false(size(im));
for idx = 1 : size(bbox,1)
outImg(bbox(idx,2):bbox(idx,2)+bbox(idx,4), ...
bbox(idx,1):bbox(idx,1)+bbox(idx,3)) = true;
end
% Close with a very large structuring element
se = strel('square', 20);
outImg2 = imclose(outImg, se);
% Find the perimeter of this object, then take the original image and
% the pixels that belong to this boundary. Colour all of these pixels red
% for illustration
redChan = imorig(:,:,1);
greenChan = imorig(:,:,2);
blueChan = imorig(:,:,3);
perim = bwperim(outImg2,8);
redChan(perim) = 255;
greenChan(perim) = 0;
blueChan(perim) = 0;
out = cat(3,redChan,greenChan,blueChan);
figure;
subplot(1,2,1);
imshow(imorig);
title('Original image');
subplot(1,2,2);
imshow(out);
title('Image with perimeter overlaid');

回答 (1 件)

KSSV
KSSV 2019 年 2 月 6 日
編集済み: KSSV 2019 年 2 月 6 日
Check the sizes of perim and redChan . They are
perim 220x684 150480 logical
redChan 219x683 149577 uint8
When you use :
redChan(perim) = 255;
YOu are trying to extract more number of dimensions, then existing. So the error. YOu need to do proper intiailizations.
  2 件のコメント
ezhil K
ezhil K 2019 年 2 月 6 日
OK.So what should I specify there?
KSSV
KSSV 2019 年 2 月 6 日
Use imcrop and get the both images to the same dimension.....

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFeature Detection and Extraction についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by