how to save the image

I have the folowing code ,plz tell how to save the circled image
k is my image
function [x1 y1 r ] = circle_saptha4(k)
ok = 0;
nim = k;
while ok~=1
% figure;
imshow(nim);
pt = ginput(2)
x1 = pt(1,1);
y1 = pt(1,2);
x2 = pt(2,1);
y2 = pt(2,2);
xpt = [x1 x2];
ypt = [y1 y2];
%line(x,y); % Enablw this for draw rectangle on circle
r = sqrt((x2-x1)^2 + (y2-y1)^2)
pp=rsmak('circle',r,[x1 y1]);
% figure;
% imshow(k)
fnplt(pp);
line(xpt,ypt);
xtl = x1-r;
xtr = x1+r;
xbl = x1-r;
xbr = x1+r;
ytl = y1+r;
ytr = y1+r;
ybl = y1-r;
ybr = y1-r;
x = [xtl xtr xbr xbl xtl];
y = [ytl ytr ybr ybl ytl];
%line(x,y);
for i=1:size(k,1)
for j=1:size(k,2)
x2 = j;
y2 = i;
val = floor(sqrt((x2-x1)^2 + (y2-y1)^2));
if(val == floor(r))
nim(i,j,1) = 255;
nim(i,j,2) = 0;
nim(i,j,3) = 0;
% else
% nim(i,j,1) = k(i,j,1);
% nim(i,j,2) = k(i,j,2);
% nim(i,j,3) = k(i,j,3);
% end
end
end
ok = (menu('Do u want to draw another circle?','No','Yes')==1)
% hold on
end
end

 Respuesta aceptada

Image Analyst
Image Analyst el 16 de Feb. de 2013

0 votos

Why not use rectangle() to draw the circles into the overlay, then use export_fig (from the File Exchange) to save the image with the circles written into the image?

Más respuestas (2)

Thorsten
Thorsten el 14 de Feb. de 2013

0 votos

imwrite(nim, 'newimage.png');

6 comentarios

FIR
FIR el 15 de Feb. de 2013
Editada: Image Analyst el 16 de Feb. de 2013
i did it but it writes only 255
Walter Roberson
Walter Roberson el 15 de Feb. de 2013
Editada: Walter Roberson el 15 de Feb. de 2013
Are you saying that the entire output image consists of (255,255,255) RGB triples ?
What is being passed in for "k" ?
FIR
FIR el 16 de Feb. de 2013
Editada: Image Analyst el 16 de Feb. de 2013
k is my image. k is peppers.png
Walter Roberson
Walter Roberson el 16 de Feb. de 2013
You didn't answer my first question
Are you saying that the entire output image consists of (255,255,255) RGB triples ?
Also I notice that your outputs are x1, y1, r, but not nim, and that you do not display nim ?
FIR
FIR el 18 de Feb. de 2013
i have imshow(nim) so image is displayed ,by calling this function,i dont know what u mean by RGB triples
Walter Roberson
Walter Roberson el 18 de Feb. de 2013
Editada: Walter Roberson el 18 de Feb. de 2013
Why do you change nim after you display it?
Why do you return x1 y1 only for the newest circle, instead of for all circles? You never even displayed that newest circle on the drawing.
What is your reason for saying "I did it but it writes only 256" ? What writes only 256 ?

Iniciar sesión para comentar.

dsfds
dsfds el 14 de Mayo de 2013
Editada: dsfds el 14 de Mayo de 2013

0 votos

wanna know how to how to save images to different formats in c#

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

FIR
el 14 de Feb. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by