Image processing code Help

1 view (last 30 days)
Anas Bilal
Anas Bilal on 16 Apr 2020
Commented: Anas Bilal on 17 Apr 2020
NEED help to use imread for 20 images together. This code can work on 1 image at a time i want to use this code for all 20 images at once and want to save all images in one new folder after processing .Please can anyone help me to modify this code.
RGB=imread('1.jpg');
% input 768*576 pixel uint8 type true color image.
R=RGB(:,:,1);
% red surface image extraction
G=RGB(:,:,2);
B=RGB(:,:,3);
figure;
imshow(RGB)
title('original image');
% create a new empty graphics window
% view images
figure,
imshow(R)
title('red face version');
figure,
imshow(G)
title('green face version');
figure,
imshow(B)
  3 Comments
Anas Bilal
Anas Bilal on 16 Apr 2020
Image type is .jpg

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 16 Apr 2020
Edited: Ameer Hamza on 16 Apr 2020
Here is a general structure of the code
files = dir('*.jpg'); % get name of all files with jpg extension
for i=1:numel(files) % run the for loop over all images
name = files(i).name; % get name of i-th image file
img = imread(name); % load the image
R=RGB(:,:,1);
% red surface image extraction
G=RGB(:,:,2);
B=RGB(:,:,3);
imwrite(R, ['img' num2str(i) ' red.jpg']);
imwrite(G, ['img' num2str(i) ' green.jpg']);
imwrite(B, ['img' num2str(i) ' blue.jpg']);
end
  20 Comments
Anas Bilal
Anas Bilal on 17 Apr 2020
Great work thank you very much .

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!