我做了高斯滤波,图像变成索引。我必须使用imagesc来显示确定色差的方法。如何将其转换为rgb,以便进行进一步的处理。
编辑的添加了一些图片,顶部分别是“原始图像”、“imshow(C)”和“imagesc(C)”。然后我只想让'C‘变量像图像一样。有可能吗??



编辑的这里是我的编码,从高斯继续看
% 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;发布于 2012-02-10 10:45:11
RGB = ind2rgb(X,map)RGB在这一点上只是眼中钉,你不能神奇地添加不存在的信息。
编辑
在您的代码中,C是一个灰度图像,因为B是灰色的,这是由于它是由来自图像的渐变dIx和dIy组成的,因此您自己使用行Jgray = double(rgb2gray(J));显式地生成灰度。
https://stackoverflow.com/questions/9225468
复制相似问题