フィルターのクリア

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...

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

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by