我做了高斯滤波器,图像变得指数。我不得不使用imagesc
展现确定的色差。我如何将它转换为rgb,以便我可以进一步处理。如何转换索引图像为RGB图像MATLAB?
编辑添加了一些图像,顶部分别是'原始图像','imshow(C)','imagesc(C)'。然后我只想让'C'变量像imagec图像。可能吗??
编辑这里是我的编码,高斯看起
% Read Image
rgb = imread('barcode.jpg');
% Resize Image
rgb = imresize(rgb,0.33);
%figure(),imshow(rgb);
% Convert from RGB to Gray
Igray = rgb2gray(rgb);
BW2 = edge(Igray,'canny');
%figure(),imshow(BW2);
% Perform the Hough transform
[H, theta, rho] = hough(BW2);
% Find the peak pt in the Hough transform
peak = houghpeaks(H);
% Find the angle of the bars
barAngle = theta(peak(2));
J = imrotate(rgb,barAngle,'bilinear','crop');
%figure(),imshow(J);
Jgray = double(rgb2gray(J));
% Calculate the Gradients
[dIx, dIy] = gradient(Jgray);
%if min(dIx(:))<= -100 && max(dIx(:))>=100 || min(dIy(:))<=-100 && max(dIy(:))>=100
if barAngle <= 65 && barAngle >=-65 && min(dIx(:))<= -100
B = abs(dIx) - abs(dIy);
else
B = abs(dIy) - abs(dIx);
end
% Low-Pass Filtering
H = fspecial('gaussian', 20, 10);
C = imfilter(B, H);
C = imclearborder(C);
figure(),imshow(C);
figure(),imagesc(C);colorbar;
有可能是在这个过程中一些错误,如果应用在RGB高斯,得到了单通道图像。你能显示代码吗? – 2012-02-10 12:03:35