Borrar filtros
Borrar filtros

imwrite from polar surf

2 visualizaciones (últimos 30 días)
Pete
Pete el 12 de Nov. de 2014
Editada: Pete el 18 de Nov. de 2014
Hi all,
I'm looking to write image from a polar-plot which is essentially a sine/cosine plot, rotationally symmetric, and have it output as the 'surf' is displayed. I'm only using red channel, and the surf function plots it correctly, but imwrite converts it to a linear sinusoidal plot.
Here's the output surf and imwrite bmp (need bmp as it keeps the red only - tiff changes it to greyscale)
As you can see, the bmp appears to be as a function of Z,R, when I would like it to be XYZ. I can plot in XYZ using the surf without polar system, but I then want the image to be round (missing the "wings"):
Help would be appreciated as this is really my first program set.
Code used is attached for each: Polar.m is the round surf, but the linear image; Cartes.m is the XYZ plot, but the image with wings (codes have been edited so as to work easier, but functionality remains same).
Many thanks everyone,
Pete.
  6 comentarios
Star Strider
Star Strider el 12 de Nov. de 2014
My pleasure!
I deleted it because you didn’t accept it or vote it. A lot of us here do that, because it prevents ‘answer pollution’. I didn’t keep that particular code in the file I use to test Answers I post here because it wasn’t generally applicable (so unlikely to be useful elsewhere). I’m glad you found it useful.
Image Analyst
Image Analyst el 13 de Nov. de 2014
? I never delete answers just because no one accepted them or voted for them.

Iniciar sesión para comentar.

Respuesta aceptada

Pete
Pete el 18 de Nov. de 2014
Editada: Pete el 18 de Nov. de 2014
I've ended up using the latter function (Cartesian), and then applying a cropping mask for the final result. I'm generating a Fresnel Zone Plate for small pixel device, so started from scratch and this is now completed with various input options and a round single channel (from RGB) zone plate being generated. Thanks for the help everyone - it's through a few questions that the code is working as required.

Más respuestas (1)

Kelly Kearney
Kelly Kearney el 12 de Nov. de 2014
If your polar plot already appears as you need it to, it might be easiest to simply steal the data from the plot rather than calculating it. That way you don't have to deal with interpolating white pixels to the region outside your plot (the wings).
% Calculations
NumberWaves = 5;
Each_Division = 0.1;
rmax = NumberWaves * (2 * pi) ;
r = linspace(0, rmax, 100);
theta = linspace(0, 2*pi, 100);
[r,theta] = meshgrid(r, theta);
z = (sin(r) + 1)./2;
x = r .* cos(theta);
y = r .* sin(theta);
% Plot as you want your final image file to appear
hf = figure('units','pixels', 'position', [10 10 300 300]); % size appropriately
ha = axes('position', [0 0 1 1]);
pcolor(x,y,z);
shading flat;
cmap = [linspace(0,1,101)' zeros(101,2)];
colormap(cmap);
set(ha, 'xtick', [], 'ytick', []);
% Grab image data from the axis and save it
im = frame2im(getframe(ha));
imwrite(im, 'test.png');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by