How process all images in one Time
조회 수: 2 (최근 30일)
이전 댓글 표시
I have this code for only one image, How can i change code to process all images in one time.
clear all;
clc;
%% Getting the input images
% disp('Provide the main image...')
[img_file1, img_path1] = uigetfile({'*.png'});
img1 = imread([img_path1,img_file1]);
% disp('Provide the image to be concealed...')
[img_file2, img_path2] = uigetfile({'*.png'});
img2 = imread([img_path2,img_file2]);
%% Conditioning of images
%checking for coloured images
if length(size(img1))==3
img1 = rgb2gray(img1);
end
if length(size(img2))==3
img2 = rgb2gray(img2);
end
%checking for unequal sizes of both images
[r1,c1] = size(img1);
[r2,c2] = size(img2);
r = min(r1,r2);
c = min(c1,c2);
img1 = imresize(img1,[r c]);
img2 = imresize(img2,[r c]);
%% Performing steganography
disp('Performing steganography')
final_img = img1;
for i=1:r
for j=1:c
num1 = bitand(img1(i,j),248);
num2 = bitshift(img2(i,j),-5);
final_img(i,j) = bitor(num1,num2);
end
end
%% Recovering the concealed image
disp('Recovering the concealed image')
recovered_img = final_img;
for i=1:r
for j=1:c
recovered_img(i,j) = bitshift(final_img(i,j),5);
end
end
답변 (1개)
Walter Roberson
2022년 11월 4일
You cannot process all of the images at the same time. imread() is not able to read more than one file at a time.
You can read the files one at a time. If you make the files all the same size, you can potentially combine the contents into a single array and process the array.
if length(size(img1))==3
img1 = rgb2gray(img1);
I would remind you of the hint I gave at the end of my answer to your previous question,
in particular the bit about how augmented image data store can automatically resize files and automatically convert to color or gray.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!