RGB TO GRAY ERROR
2 次查看(过去 30 天)
显示 更早的评论
x= 1:150;y=1:150;
[p,q]=freqspace(150);
[X,Y]=meshgrid(p,q);
R=(X.^2 + Y.^2);
Lambda=633*10^-9;
dis=10*10^-3;
F = (exp(i.*pi.*R))./(Lambda.*dis);
mesh(imag(F));
there is an ouput which i have to convert into gray image.
HOW to convert into gray image...i have an error
Map myst be m*3 matrix?
how will i do this?
6 个评论
Image Analyst
2014-8-23
F is not a grayscale image! Is this not solved yet? Did you see my solution?
采纳的回答
Youssef Khmou
2014-8-23
This is numeric problem, no need for images processing tools, in fact you are computing a type of two dimensional exponential function, you have many ways to visualize your function :
figure; surface(abs(F))
2 个评论
更多回答(1 个)
Image Analyst
2014-8-23
编辑:Image Analyst
2014-8-23
TULIKA, I know you already accepted an answer, so maybe you don't need my answer anymore, but I had this already to post and then I got to watching a movie and didn't post it until now. Well, for whatever it's worth, here it is. If it helps in any way, maybe you can vote for it:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 13;
x= 1:150;y=1:150;
[p,q]=freqspace(150);
[X,Y]=meshgrid(p,q);
R=(X.^2 + Y.^2);
Lambda=633*10^-9;
dis=10*10^-3;
F = (exp(i.*pi.*R))./(Lambda.*dis);
% Convert into a gray scale image and display it as a mesh.
subplot(1, 3, 1);
grayImage = imag(F); % Gray scale image = imaginary part.
mesh(grayImage);
axis square
title('Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Display grayscale image.
subplot(1, 3, 2);
imshow(grayImage, []);
title('Grayscale Image', 'FontSize', fontSize);
colormap(gray(256));
colorbar;
% Convert into a color image, just for fun
rgbImage = ind2rgb(uint8(255*mat2gray(grayImage)), jet(256));
subplot(1, 3, 3);
imshow(rgbImage, []);
title('RGB Image', 'FontSize', fontSize);
6 个评论
Image Analyst
2014-8-23
You're basically convolving that image with itself, which is an autocorrelation, so you should see a spike at the middle, followed by a rapid fall off. Of course the second half of your code has nothing to do with the first half of your code. What are you attempting to achieve? Perhaps you should start a new discussion if we're going to be talking about new topics of convolution or autocorrelation or spatial filtering, as you've already marked this one as Accepted and many people may not bother to look anymore.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!