imagesc を使用して積分画像を取得しています。ただし、表示することしかできず、手動で保存する必要があります.imwriteまたはimsaveを使用してスクリプトから画像を保存する方法が見つかりません。それはまったく可能ですか?
コード:
image='C:\image.jpg';
in1= imread((image));
in=rgb2gray(in1);
in_in= cumsum(cumsum(double(in)), 2);
figure, imagesc(in_in);
印刷コマンドを使用することもできます。たとえば、複数の画像を実行していて、それらをシリアル化して保存したい場合は、次のようにすることができます:
% Create a new figure
figure (fig_ct)
% Plot your figure
% save the figure to your working directory
eval(['print -djpeg99 ' num2str(fig_ct)]);
% increment the counter for the next figure
fig_ct = fig_ct+1;
はただのfig_ct
カウンターです。jpeg 以外の別の形式で保存することに興味がある場合は、ドキュメントを参照してください。tiff、eps、およびその他多数の形式を使用できます。
お役に立てれば
I believe your problem may be with the fact that you are saving a double matrix that is not on the range of [0 1]. If you read the documentation, you'll see that
If the input array is of class double, and the image is a grayscale or RGB color image, imwrite assumes the dynamic range is [0,1] and automatically scales the data by 255 before writing it to the file as 8-bit values.
You can convert it yourself to a supported type (that's logical, uint8, uint16, or double) or get it in the range [0 1] by, for example, dividing it by the max:
imwrite (in_in / max (in_in(:)), 'out.jpg');
You may still want to further increase the dynamic range of the image you saved. For example, subtract the mininum before dividing by the max.
in_in = in_in - min (in_in(:));
in_in = in_in / max (in_in(:));
imwrite (in_in, 'out.jpg');
If you want exactly what imagesc
displays
The
imagesc
function scales image data to the full range of the current colormap.
I don't know what exactly does it mean exactly but call imagesc requesting with 1 variable, and inspect the image handle to see the colormap and pass it to imwrite()
.
私は非常に新しいプログラマーなので、これがあまり役に立たない場合は事前にお詫びしますが、同じ問題が発生し、なんとかそれを理解することができました. uint8 を使用して、次のように変換しました。
imwrite(uint8(in_in), 'in_in.jpg', 'jpg');