error !! horzcat CAT arguments dimensions are not consistent.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Jan
le 17 Oct 2013
Modifié(e) : Jan
le 17 Oct 2013
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.
Réponse acceptée
Vivek Selvam
le 17 Oct 2013
Modifié(e) : Vivek Selvam
le 17 Oct 2013
Vidya, you can solve your padding problem by
- switching vertcat and horzcat (reasoning in the comment below)
- 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 commentaires
Vivek Selvam
le 17 Oct 2013
%%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)
Plus de réponses (1)
Jan
le 17 Oct 2013
Modifié(e) : Jan
le 17 Oct 2013
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!
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!