sketch recognition
이전 댓글 표시
I AM USING THIS PROGRAM FOR SKETCH RECOGNITION HOWEVER IT IS GIVING ME THE ERROR ??? Subscripted assignment dimension mismatch.
Error in ==> sym_rec_main2 at 60 I3Dtotal(:,:,2) = Ibw3D2;
WHAT AM I DOING WRONG?
I3D1 = imread('IMG_0001.jpg');
I3D2 = imread('IMG_0002.jpg');
I3D3 = imread('IMG_0003.jpg');
I3D4 = imread('IMG_0004.jpg');
size3Dr = input('Enter number of training sets');
size3Dc = input('Enter number of different symbols');
sizer = size3Dr; %Assuming equal traning sets
sizec = size3Dc;
noimages = sizer/6;
Igray1 = rgb2gray(I3D1);
Ibw3D1 = im2bw(Igray1,graythresh(Igray1));
Igray2 = rgb2gray(I3D2);
Ibw3D2 = im2bw(Igray2,graythresh(Igray2));
Igray3 = rgb2gray(I3D3);
Ibw3D3 = im2bw(Igray3,graythresh(Igray3));
Igray4 = rgb2gray(I3D4);
Ibw3D4 = im2bw(Igray3,graythresh(Igray4));
I3Dtotal(:,:,1) = Ibw3D1;
I3Dtotal(:,:,2) = Ibw3D2;
I3Dtotal(:,:,3) = Ibw3D3;
I4Dtotal(:,:,3) = Ibw3D4;
rfactor = 1; crpval = 0;
for i = 1 : noimages
I = I3Dtotal(:,:,i);
img = sym_rec_img_preprocess(I, size3Dr, size3Dc, noimages);
for cnt = 1:((size3Dr*size3Dc)/noimages)
bw2 = img_crop(img{cnt}, rfactor, crpval);
charvec = img_resize(not(bw2));
out3D(:,cnt,i) = charvec;
end
end
답변 (2개)
Walter Roberson
2011년 4월 6일
0 개 추천
Use size() to check that all of the I3D* image arrays are the same size.
댓글 수: 5
stephanie borg
2011년 4월 6일
Walter Roberson
2011년 4월 6일
You can prevent the error by using code like this:
maxdims = max([size(Ibw3D1); size(Ibw3D2); size(Ibw3D3); size(Ibw3D4)]);
I3Dtotal = zeros([maxdims(1), maxdims(2), 4], class(Ibw3D4));
I3Dtotal(1:size(Ibw3D1,1),1:size(Ibw3D1,2),1) = Ibw3D1;
I3Dtotal(1:size(Ibw3D2,1),1:size(Ibw3D2,2),1) = Ibw3D2;
I3Dtotal(1:size(Ibw3D3,1),1:size(Ibw3D3,2),1) = Ibw3D3;
I3Dtotal(1:size(Ibw3D4,1),1:size(Ibw3D4,2),1) = Ibw3D4;
This will use zeros in the locations where the arrays were smaller.
Alternately, you could use,
mindims = min([size(Ibw3D1); size(Ibw3D2); size(Ibw3D3); size(Ibw3D4)]);
and then you could
Ibw3D1 = imresize(Ibw3D1,mindims);
Ibw3D2 = imresize(Ibw3D2,mindims);
and so on, after which you could use your existing Ibwtotal code. This would not use zero padding anywhere, but would have the disadvantage of interpolating some of the arrays to fit the smallest size which will introduce artifacts. (You could resize to maxdims instead of mindims if you wanted.)
stephanie borg
2011년 4월 6일
Walter Roberson
2011년 4월 6일
It is 07:00 here and I am going to bed in a moment. It is better to post your questions as others may be able to answer them. Especially if they are questions about the sketch recognition portion, as I am not familiar with the techniques used for sketch recognition.
stephanie borg
2011년 4월 6일
Tim Zaman
2011년 4월 6일
0 개 추천
The images you are using in this code have to be the exact amount of pixels: so if image 1 is 800x600, image 2 has to be 800x600 too. Common error with image processing.
댓글 수: 2
stephanie borg
2011년 4월 6일
Walter Roberson
2011년 4월 6일
You could use the imresize() suggestion I made earlier. You will have to decide whether you want to size the small images up, or the larger images down.
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!