views:

66

answers:

2

How to avoid jagged image in matlab. I have 600 x 600 image opened in matlab and do some processing on the image. However when I save it, it look so blur and jagged. What should I do?

EDITED: this question is related to my previous question here http://stackoverflow.com/questions/3178336/matlab-how-to-plot-x-y-on-image-and-save

fid=fopen(datafile.txt);
A=textscan(fid,'%f%f%f'); %read data from the file
code  =A{1};
xfix  =A{2};
yfix  =A{3};


for k=1:length(code)
    imagefile=code(k);
    rgb = imread([num2str(imagefile) '.jpg']);
    imshow(rgb);
    hold on;
    x = xfix2(k);
    y = yfix2(k);
    plot(x,y,'-+ b'); % plot x,y on the 
    saveas(([num2str(imagefile) '.jpg'])) % save the image with the same name as it open
end
hold off
A: 

If it is just a resolution issue, perhaps using the print command (as listed below) with an explicit resolution option may fix it.

print(gcf,'-djpeg','-r600',[num2str(imagefile)])
arun
A: 

My guess would be JPEG compression artifacts. JPEG isn't a great format for data with a lot of high frequency components. Have you tried turning the compression down? Like so:

imwrite(f.cdata,([num2str(imagefile) '.jpg']),'Quality',100);

The default for the quality parameter is only 75. That's plenty for a lot of cases, but you might need more.

MPG
@MPG thanks the image are more clear now :) ...but the "+" which I used to plot the xy coordinate, which I set in blue color, turn into black color when I saved it. Why?
Jessy