error !! horzcat CAT arguments dimensions are not consistent.

조회 수: 1 (최근 30일)
vidya
vidya 2013년 10월 17일
댓글: Vivek Selvam 2013년 10월 17일
hi sir i am very much new to matlab ..i have two images ..i want to use "imoverlay" for the images but whenever i run it ,i get error saying horzcat arguments dimension are consistent ..i am working on retinal image analysis..belo i have uploaded my code and error.sorry for not providing sufficient info error is" horzcat CAT arguments dimensions are not consistent.
Error in ==> file1>filter_Callback at 692 C = horzcat(I2,1);"
  댓글 수: 3
Jan
Jan 2013년 10월 17일
편집: Jan 2013년 10월 17일
Please take into account that problem is not urgent. The fact, that you have to submit it tomorrow does not encourage people to stop their work and care about your problem at first.
If you really want the forum to help yout, remove the "urgent" and insert a copy of the complete error message, instead of the short paraphrased version. Then we would not have to guess, where the problem occurres.
vidya
vidya 2013년 10월 17일
sorry sir :-( :-(

댓글을 달려면 로그인하십시오.

채택된 답변

Vivek Selvam
Vivek Selvam 2013년 10월 17일
편집: Vivek Selvam 2013년 10월 17일
Vidya, you can solve your padding problem by
  1. switching vertcat and horzcat (reasoning in the comment below)
  2. image is 3 dimensional matrix (the 3rd dimension for the rgb color)
Here is the fixed code:
%Pad the columns
if size(I1,1) > size(I2,1) %I1 has more rows so pad I2
pad = zeros (size(I1,1) - size(I2,1), size(I2,2),size(I2,3));
%I2 = [I2 ; pad]; %Append the rows of zeros to the bottom of I2
I2 = vertcat(I2,pad); % vertical concatenation as you pad rows
else %I2 has more rows so pad I1
pad = zeros (size(I2,1) - size(I1,1), size(I1,2),size(I1,3));
%I1 = [I1 ; pad]; %Append the rows of zeros to the bottom of I1
I1 = vertcat(I1,pad); % vertical concatenation as you pad rows
end
%Pad the columns
if size(I1,2) > size(I2,2) %I1 has more rows so pad I2
pad = zeros (size(I2,1), size(I1,2) - size(I2,2),size(I2,3));
%I2 = [I2 , pad]; %Append the columns of zeros to the left of I2
I2 = horzcat(I2,pad); % horizontal concatenation as you pad columns
else %I2 has more rows so pad I1
pad = zeros (size(I1,1), size(I2,2) - size(I1,2),size(I1,3));
% I1 = [I1 , pad]; %Append the columns of zeros to the left of I1
I1 = horzcat(I1,pad); % horizontal concatenation as you pad columns
end
ovr1=imoverlay(I1,I2,[0,0,0]); % overlaying updated images
  댓글 수: 4
vidya
vidya 2013년 10월 17일
sir its the paper i am implementing...i completed 10 steps of it now i am in 11 step
Vivek Selvam
Vivek Selvam 2013년 10월 17일
You can check out the detailed blog on this subject here.
%%ML Answers
fig1 = imread('gg1.jpg'); % original
fig2 = rgb2gray(imread('gff.jpg')); % gray - influence map
% Display the original image
figure; imshow(fig1, 'InitialMag', 'fit');
% Make a truecolor all-blue image.
[m n] = size(fig2);
B = cat(3, zeros(m,n), zeros(m,n), ones(m,n));
hold on
h = imshow(B);
% Use our influence map as the AlphaData for the solid blue image.
set(h, 'AlphaData', fig2)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2013년 10월 17일
편집: Jan 2013년 10월 17일
Let me guess, where the problem is:
pad = zeros (size(I1,1) - size(I2,1), size(I2,2));
%I2 = [I2 , pad]; %Append the rows of zeros to the bottom of I2
C = horzcat(I2, pad);
Here the 1st dimension of pad does not match, because it must be size(I2, 1).
Guessing is inefficient. Please do not post a question without showing the complete error message in the future. Thanks!
  댓글 수: 1
vidya
vidya 2013년 10월 17일
sir i did the same ..but still the error is same...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by