필터 지우기
필터 지우기

imwrite from polar surf

조회 수: 2 (최근 30일)
Pete
Pete 2014년 11월 12일
편집: Pete 2014년 11월 18일
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
Star Strider
Star Strider 2014년 11월 12일
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 2014년 11월 13일
? I never delete answers just because no one accepted them or voted for them.

댓글을 달려면 로그인하십시오.

채택된 답변

Pete
Pete 2014년 11월 18일
편집: Pete 2014년 11월 18일
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.

추가 답변 (1개)

Kelly Kearney
Kelly Kearney 2014년 11월 12일
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');

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by