Image Cdata cannot be complex!!!

18 次查看(过去 30 天)
hello..i am working on a code which gives me this error Error using ==> image Error using ==> image Image CData can not be complex
Error in ==> imagesc at 19 hh = image(varargin{1},'CDataMapping','scaled');
Error in ==> file1>GABOR_Callback at 794 h = imagesc( gb ); % show the edge image
i dont no how to solve it..help me please..
I = getimage();
I=I(:,:,2);
lambda = 8;
theta = 0;
psi = [0 pi/2];
gamma = 0.5;
bw = 1;
N = 1;
img_in = im2double(I);
%img_in(:,:,2:3) = []; % discard redundant channels, it's gray anyway
img_out = zeros(size(img_in,1), size(img_in,2), N);
for n=1:N
gb = gabor_fn(bw,gamma,psi(1),lambda,theta)...
+ 1i * gabor_fn(bw,gamma,psi(2),lambda,theta);
% gb is the n-th gabor filter
%img_out(:,:,n) = imfilter(img_in, gb, 'symmetric');
% filter output to the n-th channel
figure(1);
imshow(img_in);
title('input image');
figure(2);
imshow(gb);
theta = 15 * n; % next orientation
% Get size of existing image A.
A=img_in;
B=gb;
[rowsA colsA numberOfColorChannelsA] = size(img_in);
% Get size of existing image B.
[rowsB colsB numberOfColorChannelsB] = size(gb);
% See if lateral sizes match.
if rowsB ~= rowsA || colsA ~= colsB
% Size of B does not match A, so resize B to match A's size.
B = imresize(B, [rowsA colsA]);
end
imshow(img_in);
hold on;
h = imagesc( gb ); % show the edge image
set( h, 'AlphaData', .5 ); % .5 transparency
colormap gray ;
end

采纳的回答

Wayne King
Wayne King 2013-11-8
If you are taking the Gabor transform, you like want to display the magnitude image, change the line
h = imagesc(gb);
to
h = imagesc(abs(gb));
  3 个评论
vidya
vidya 2013-11-8
编辑:vidya 2013-11-8
sorry for delay sir ...
f=size(r); f
f =
900 1200 3
sir i have two lines of code..could you please tell me what is happening here.
img_out_disp = sum(abs(img_out).^2, 3).^0.5;
%default superposition method, L2-norm
img_out_disp = img_out_disp./max(img_out_disp(:));
%normalize
imshow(img_out_disp);

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by