2012-02-10 76 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

相關問題