我做了高斯濾波器,圖像變得指數。我不得不使用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