How to take a given plot and write it as an image
1 回表示 (過去 30 日間)
古いコメントを表示
I have created the plot of an ellipse that is shaded in successfully. now i would like to take that plot and write it to an image, say "pic.jpg"
Here is the code so far:
function out = drawEllipse(x1,y1,x2,y2,h,w,d)
P = zeros(800,800);
P(1:800,1:800) = uint8(255);
[h,w] = size(P);
imagesc(P),colormap white,hold on;
c = 1/2*sqrt((x2-x1)^2+(y2-y1)^2);
a = d/2;
b = sqrt(a^2-c^2);
t = linspace(0,2*pi,1000);
x = (x1+x2)/2 +(x2-x1)/(2*c)*a*cos(t) - (y2-y1)/(2*c)*b*sin(t);
y = (y1+y2)/2 +(y2-y1)/(2*c)*a*cos(t) +(x2-x1)/(2*c)*b*sin(t);
plot(x,y)
fill(x,y,'black');
axis equal
what i actually want to do is to add another input to the function, being "pic.jpg" and actually write this plot to the image file in the function.
any thoughts? thanks for all your help! you all have been very helpful thus far!
0 件のコメント
回答 (1 件)
Image Analyst
2014 年 12 月 7 日
Try export_fig() http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig the most downloaded File Exchange submission of all time.
Even the Mathworks recommends it:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!