필터 지우기
필터 지우기

Error. Inputs must have the same size

조회 수: 16 (최근 30일)
Bucica  Nicolae
Bucica Nicolae 2017년 3월 16일
답변: Nazish Iqbal 2020년 1월 7일
Hello ,I recive the following error for the code bellow .Can you help me please?
Error using bitor.Inputs must have the same size. (line 12)
clc;
clear all;
close all;
cover = input('alegeti poza' , 's');
message = input('introduceti textul dorit ', 's');
x = imread(cover); % cover message
y = imread(message); % message image
n = 3 %input('Enter the no of LSB bits to be subsituted- ');
S = uint8(bitor(bitand(x,bitcmp(2^n-1,8)),bitshift(y,n-8))); %Stego
E = uint8(bitand(255,bitshift(S,8-n))); %Extracted
origImg = double(y); %message image
distImg = double(E); %extracted image
[M N] = size(origImg);
distImg1=imresize(distImg,[M N]);
error = origImg - distImg1;
MSE = sum(sum(error .* error)) / (M * N);
if(MSE > 0)
PSNR = 10*log10(M*N./MSE);
else
PSNR = 99;
end
disp('PSNR of message image to extracted image is')
disp(abs(PSNR))
disp('MSE is')
disp(abs(MSE))

채택된 답변

Jan
Jan 2017년 3월 16일
편집: Jan 2017년 3월 16일
The message means, that this fails:
bitor(bitand(x, bitcmp(2^n-1, 8)), bitshift(y, n-8))
Because the bitand and bitshift do not change the size of the inputs, the error is caused by the different sizes of x and y. Is it assumd that both images have the same size? If not, how do you want to consider different sizes?
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 3월 16일
One difficulty to watch out for is that one of your images might be stored as RGB even though it looks like greyscale, and the other might be stored as true grayscale.
But more likely your images are just different sizes. You should be taking into account that the message will seldom be exactly the same size as the cover image.

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

추가 답변 (2개)

john j sanabria
john j sanabria 2017년 10월 21일
nop the error is about bitcmp(2^n-1,8), any n it just said "Error using bitcmp ASSUMEDTYPE must be an integer type name."
  댓글 수: 2
Jan
Jan 2017년 10월 21일
But the OP has explained:
Error using bitor.Inputs must have the same size. (line 12)
In older Matlab versions, e.g. R2009a, the 2nd input of bitcmp was a numerical value.
john j sanabria
john j sanabria 2017년 10월 21일
one possible solution is "bitand(x,bitcmp(2^n-1,'uint8')" with MATLAB Version: 9.0.0.341360 (R2016a)

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


Nazish Iqbal
Nazish Iqbal 2020년 1월 7일
%ENCRYPTION
clear all
%READ THE COVER IMAGE
I = imread('C:\Users\dell\Desktop\peppers.jpg');
%READ THE IMAGE TO HIDE
J = imread('C:\Users\dell\Desktop\cube.jpg');
%PREALLOCATE THE OUTPUT IMAGE
Output = zeros(size(I));
%REPRESENT THE NUMBER OF ROWS AND COLUMNS OF THE SECRET IMAGE
%IN BINARY FORMAT
Jsize = de2bi([size(J,1),size(J,2)]);
%RED,GREEN AND BLUE COMPONENTS OF THE SECRET IMAGE
Red_Ch = J(:,:,1);
Green_Ch = J(:,:,2);
Blue_Ch = J(:,:,3);
%CONVERT THE RED COMPONENT OF THE SECRET IMAGE INTO BINARY FORMAT
Encrypt_Red = de2bi(Red_Ch(:),8)';
Encrypt_Red = Encrypt_Red(:)';
%CONVERT THE GREEN COMPONENT OF THE SECRET IMAGE INTO BINARY FORMAT
Encrypt_Green = de2bi(Green_Ch(:),8)';
Encrypt_Green = Encrypt_Green(:)';
%CONVERT THE BLUE COMPONENT OF THE SECRET IMAGE INTO BINARY FORMAT
Encrypt_Blue = de2bi(Blue_Ch(:),8)';
Encrypt_Blue = Encrypt_Blue(:)';
%CALCULATE THE INTERVAL AND CONVERT IT INTO BINARY FORMAT
dt=floor((size(I,1)*size(I,2))/numel(Encrypt_Red));
Bi_dt = de2bi(dt,8);
Info_data = [Bi_dt,Jsize(1,:),Jsize(2,:)];
%RED,GREEN AND BLUE COMPONENT OF THE COVER IMAGE
Red_mat = I(:,:,1);
Green_mat = I(:,:,2);
Blue_mat = I(:,:,3);
% INTERVAL,NUMBER OF COLUMNS, NUMBER OF ROWS
Red_mat(1:24) = bitset(Red_mat(1:24),1,Info_data);
Green_mat(1:24) = bitset(Green_mat(1:24),1,Info_data);
Blue_mat(1:24) = bitset(Blue_mat(1:24),1,Info_data);
%%REPLACE THE LEAST SIGNIFICANT BIT OF THE COVER IMAGE
%WITH THE BINARY FORMAT OF THE SECRET IMAGE
EndValue = numel(Encrypt_Red)*dt+24;
Red_mat(25:dt:EndValue) = bitset(Red_mat(25:dt:EndValue),1,Encrypt_Red);
Green_mat(25:dt:EndValue) = bitset(Green_mat(25:dt:EndValue),1,Encrypt_Green);
Blue_mat(25:dt:EndValue) = bitset(Blue_mat(25:dt:EndValue),1,Encrypt_Blue);
%ENCRYPTED IMAGE
Output(:,:,1) = Red_mat;
Output(:,:,2) = Green_mat;
Output(:,:,3) = Blue_mat;
Output = uint8(Output);
figure,subplot(121),imshow(I); subplot(122),imshow(Output);
%DIFFERENCE BETWEEN THE ORIGINAL AND THE ENCRYPTED IMAGE
figure,imagesc(double(I)-double(Output));colormap(jet);colorbar;
%WRITE THE ENCRYPTED IMAGE IN THE PNG FORMAT
imwrite(Output,'Encrypt_Image1.png');
stuck in line 52.kindly help me
error.PNG

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by