Problem with data class when working in GUI...... plz help....

4 views (last 30 days)
I am working in image watermarking, I m embedding a BMP image in Blue component of color image,
for ii=1:Mm
for jj=1:Nm
array2D(ii,jj) = bitget(blue_component(ii,jj),1);
save('array.mat','array2D');
watermarked_image(ii,jj)=bitset(blue_component(ii,jj),1,message1(ii,jj));
array2Dafter(ii,jj) = bitget(watermarked_image(ii,jj),1);
save('array2.mat','array2Dafter');
end
end
I m collecting the lsb of original blue panel in array2D to be inserted back later.
when i m running the code without making a GUI interface using Guide, array2D is of class uint8 while when i run some as a part of a pushbutton callback it is saved as class double, now while the second bitget after embedding is recovered same as uint8 both times,.. I want to get bLue_component as uint8 with gui.... i m not able to find the issue ...... plz plz plz help
  3 Comments
ankita
ankita on 22 Dec 2012
array2D = cell([Mm,Nm]); array2D=zeros(Mm,Nm);
I tried both initialization ....
and the question was reposted by mistake....
Walter Roberson
Walter Roberson on 22 Dec 2012
Saving array2D and array2Dafter in every iteration of the "for" loop does not seem to be efficient.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 22 Dec 2012
Edited: Image Analyst on 22 Dec 2012
You can change the class of a variable by casting it to the desired type using uint8(), logical(), or whatever class you want. It will round or clip the values to fit into the data type of the target class, e.g. 42.73 goes to 43 for uint8, 256 goes to 255 for uint8, 1 goes to true for logical, etc.
Perhaps you'd be interested in my demo that does LSB watermarking. Let me know and I'll post it.
  6 Comments
ankita
ankita on 22 Dec 2012
thnk you ...... thats the reason .... i was seeking for .....
Image Analyst
Image Analyst on 22 Dec 2012
So have all your questions been answered or not? Mark as answered if you're done.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 22 Dec 2012
array2D = zeros(Mm, Nm, 'uint8');
  3 Comments
Walter Roberson
Walter Roberson on 22 Dec 2012
How are you opening the array2D ?
What does
whos -file array.mat
show?
ankita
ankita on 22 Dec 2012
array2D 64x128 65536 double global when part of gui
array2D1 64x128 8192 uint8 when not part of gui

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!