2012-02-10 466 views
0

我做了高斯滤波器,图像变得指数。我不得不使用imagesc展现确定的色差。我如何将它转换为rgb,以便我可以进一步处理。如何转换索引图像为RGB图像MATLAB?

编辑添加了一些图像,顶部分别是'原始图像​​','imshow(C)','imagesc(C)'。然后我只想让'C'变量像imagec图像。可能吗??

enter image description here enter image description here enter image description here

编辑这里是我的编码,高斯看起

% 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; 
+0

有可能是在这个过程中一些错误,如果应用在RGB高斯,得到了单通道图像。你能显示代码吗? – 2012-02-10 12:03:35

回答

1
RGB = ind2rgb(X,map) 

RGB是在这一点上只是养眼,你不能神奇添加不在那里的信息。

EDIT

在代码中,C是灰度图像,因为B是灰度这方面是由它是从梯度dIxdIy组成,其从图像源自这样的事实引起的,你自己用线使灰阶明确Jgray = double(rgb2gray(J));

+0

那么我怎样才能实现这个代码到我的编码? – Kim 2012-02-10 13:44:51

+0

@Kim,这完全取决于它是什么你想在这里实现。 – Maurits 2012-02-10 14:35:50