writing an image into folder

I have 100 images in an folder ,and have performed some operation on it ,now i have subplotted those images ,so now i have single figure window,now i want to write that figure window into an folder,i have created an folder,but dont know how to write that figure window,please help
I have posted the code
clc;
close all;
f1=fullfile('D:','new');
if (exist(f1) == 0)
mkdir (f1);
end
pathname ='D:\dataset\' ;
dirlist = dir( [pathname '*.jpg'] );
pickind='jpg';
for m = 1:length(dirlist)
rgbimage=double( imread([pathname, dirlist(x).name]));
% Read standard MATLAB demo image.
%rgbImage = imread('onion.png');
% Display the original image.
subplot(3, 4, 1);
imshow(rgbImage);
title('Original RGB Image');
% Maximize figure.
set(gcf, 'Position', get(0, 'ScreenSize'));
% Split the original image into color bands.
redBand = rgbImage(:,:, 1);
greenBand = rgbImage(:,:, 2);
blueBand = rgbImage(:,:, 3);
% Display them.
subplot(3, 4, 2);
imshow(redBand);
title('Red band');
subplot(3, 4, 3);
imshow(greenBand);
title('Green band');
subplot(3, 4, 4);
imshow(blueBand);
title('Blue Band');
% Threshold each color band.
redthreshold = 68;
greenThreshold = 70;
blueThreshold = 72;
redMask = (redBand > redthreshold);
greenMask = (greenBand < greenThreshold);
blueMask = (blueBand < blueThreshold);
% Display them.
subplot(3, 4, 6);
imshow(redMask, []);
title('Red Mask');
subplot(3, 4, 7);
imshow(greenMask, []);
title('Green Mask');
subplot(3, 4, 8);
imshow(blueMask, []);
title('Blue Mask');
% Combine the masks to find where all 3 are "true."
redObjectsMask = uint8(redMask & greenMask & blueMask);
subplot(3, 4, 9);
imshow(redObjectsMask, []);
title('Red Objects Mask');
maskedrgbImage = uint8(zeros(size(redObjectsMask))); % Initialize
maskedrgbImage(:,:,1) = rgbImage(:,:,1) .* redObjectsMask;
maskedrgbImage(:,:,2) = rgbImage(:,:,2) .* redObjectsMask;
maskedrgbImage(:,:,3) = rgbImage(:,:,3) .* redObjectsMask;
subplot(3, 4, 10);
imshow(maskedrgbImage);
title('Masked Original Image');
end

답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 12월 7일

0 개 추천

doc print
More to Clarify Comments
H = figure;
for ii = 321:326
subplot(ii)
imagesc(magic(ceil(rand*10))); %random fig with 6 subplots
end
print('-dbmp256' , 'picture_of_6_subplots') %save as bmp

댓글 수: 7

Pat
Pat 2011년 12월 7일
I cant understand what u r saying ,can u explain please
Sean de Wolski
Sean de Wolski 2011년 12월 7일
tpye:
doc print
at the command line and it will explain to you how to print your figure to an image.
Pat
Pat 2011년 12월 7일
Sean i want to write that image in a folder and not to print
Sean de Wolski
Sean de Wolski 2011년 12월 7일
Did you read the documentation in doc print? If you choose your printer to be an image writer, you'll get an image. There are examples at the bottom.
Pat
Pat 2011년 12월 7일
Sean i think u did not get my question ,i have six images in a single figure window,i have uses subplot function ,i want to write it into a file ,please help
Sean de Wolski
Sean de Wolski 2011년 12월 7일
see clarification.
Titus Edelhofer
Titus Edelhofer 2011년 12월 7일
Hi Pat, please describe more detailed, what you want: do you want to save your 6 subplots to 6 different image files?

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

카테고리

도움말 센터File Exchange에서 Display Image에 대해 자세히 알아보기

질문:

Pat
2011년 12월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by