필터 지우기
필터 지우기

Error using round(resh​ape(messag​e,Mm*Nm,1)​./256)

조회 수: 2 (최근 30일)
vaishali
vaishali 2014년 11월 6일
답변: Roger Stafford 2014년 11월 6일
Hello,
What may be the problem with the following code line?
message=round(reshape(message,Mm*Nm,1)./256); using this I want to check message isn't too large to fit in cover image.
Where message=double(imread('lena.jpg')) and [Mm Nm] is the size of the message.
Thanks in advance

답변 (2개)

James Tursa
James Tursa 2014년 11월 6일
What does the error message say?
Double check the size of the variable message to make sure it really is Mm x Nm.
Note that you can replace reshape(message,Mm*Nm,1) with message(:)
  댓글 수: 2
vaishali
vaishali 2014년 11월 6일
편집: James Tursa 2014년 11월 6일
Thank you for your fast response .
The error says "To RESHAPE the number of elements must not change."
And this is the code segment
close all;
clear;
cover = imread('cheeta.jpg');
[a1 h1 v1 d1] = dwt2(cover,'haar');
[a2 h2 v2 d2] = dwt2(h2,'haar');
k=50; % set minimum coeff difference
blocksize=8; % set the size of the block in cover to be used for each bit in watermark
cover_object=h2;
%figure,imshow(cover);title('Original'); % determine size of cover image
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2);
% determine maximum message size based on cover object, and blocksize
max_message=Mc*Nc/(blocksize^2); % read in the message image
msg='lena.jpg';
message=double(imread(msg));
Mm=size(message,1); %Height
Nm=size(message,2); %Width % reshape the message to a vector
message=round(reshape(message,Mm*Nm,1)./256);
James Tursa
James Tursa 2014년 11월 6일
What is size(message)? In particular, what is size(message,3)?

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


Roger Stafford
Roger Stafford 2014년 11월 6일
Does 'lena.jpg' produce a third dimension for color? If so, that would account for your error message; you would have more than Mm*Nm elements in 'message'.

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by