I want to do the embedding operation by converting Hessenberg
Show older comments
Hello,
I divided an image into 4x4 blocks and selected blocks randomly. Now I want to click on the selected Hessenberg matrix on these selected blocks and embed a binary image in the Hessenberg matrix. Thank you for your help.
5 Comments
Walter Roberson
on 12 Feb 2022
Okay, so you break an image into blocks that are 4 x 4 x number_of_color_panes . And you select blocks out of that randomly.
Then, having selected blocks randomly, you want to proceed randomly selected block by randomly selected block, and for each one have the user click on something that is within 4 x 4 blocks ? The blocks are only 4 x 4 x 1 (grayscale) or 4 x 4 x 3 (RGB), so it is not obvious to me where you would find a Hessenberg matrix inside the 4 x 4 x 1 or 4 x 4 x 3 area? I guess it is possible, if you were having the user point out a 1 x 2 or 2 x 1 sub-matrix, I guess? And then a complete binary image is to be embeded within the selected Hessenberg matrix ?
Part of my confusion is that I do not know what you mean by a Hessenberg Matrix in this context? Or how you could embed a complete binary image inside a matrix that is going to be at most 2 x 1 x 3 or 1 x 2 x 3 ? (If it was going to be the full 4 x 4 x 1 or 4 x 4 x 3 then there would not be any point in having the user click to select a Hessenberg matrix inside the selected block -- you would just use the complete selected block.)
javad danesh
on 12 Feb 2022
javad danesh
on 12 Feb 2022
Walter Roberson
on 13 Feb 2022
I still do not understand what the purpose of the clicking is.
I also do not understand what a Hessenberg matrix is in this situation.
Are you doing something like an LU decomposition, https://www.mathworks.com/help/matlab/ref/lu.html and then modifying one element of the U matrix, and then multiplying out to construct a modified matrix?
javad danesh
on 13 Feb 2022
Edited: javad danesh
on 13 Feb 2022
Answers (2)
Cover_filename = 'flamingos.jpg';
watermark_filename = 'cameraman.tif';
CoverImage = imresize(imread(Cover_filename), [256 256]);
watermarkImage = imresize( imread(watermark_filename), [8 8] );
watermarkBits = reshape((dec2bin(watermarkImage, 8) - '0').', 1, []);
num_watermarkBits = numel(watermarkBits);
image_blocks = mat2cell(CoverImage, 4 * ones(1,size(CoverImage,1)/4), 4 * ones(1,size(CoverImage,2)/4), ones(1,size(CoverImage,3)));
num_image_blocks = numel(image_blocks);
if num_image_blocks < num_watermarkBits
error('watermark image is too big to store in the cover image');
end
selected_blocks = randperm(numel(image_blocks), num_watermarkBits);
new_blocks = image_blocks;
displayed_once = false;
for idx = 1 : num_watermarkBits
blocknum = selected_blocks(idx);
thisblock = image_blocks{blocknum};
[P, H] = hess(double(thisblock));
H1 = typecast(H(1,end), 'uint64');
H1 = typecast(bitset(H1, 64, watermarkBits(idx)), 'double');
reconstructed_block = cast(P * H * P', class(thisblock));
new_blocks{blocknum} = reconstructed_block;
end
watermarkedImage = cell2mat(new_blocks);
figure(); imshow(CoverImage); title('Cover image');
figure(); imshow(watermarkImage); title('image to watermark with');
figure(); imshow(watermarkedImage); title('image after watermarking');
imshowpair(CoverImage, watermarkedImage)
Watermarked image is the same as the original image.
8 Comments
javad danesh
on 14 Feb 2022
Walter Roberson
on 14 Feb 2022
No, embedding is not done correctly according to your earlier specifications. You indicated earlier that you wanted to break up the image into three channels, and then break each channel up into 4 x 4 blocks. If you look carefully what I do instead here take the original RGB image and break it up into 4 x 4 x 1 blocks (getting 64 x 64 x 3 blocks), and select from them randomly -- instead of working on entire channels at a time. Working one channel at a time is a change you could make.
Also, earlier you indicated "the watermark information is embedded into the biggest energy element of the Hessenberg matrix by quantization technique.". I do not know what is meant by "the biggest energy element of the Hessenberg matrix". Perhaps you mean the entry with the largest absolute value? That would match what you said about "and embed one bit instead of the maximum upper triangular matrix."
I also do not know what quantization technique you intend to use.
I did not look at the entry with the largest absolute value. Another meaning for "maximum upper triangular matrix" is the entry that is furthest from the diagonal -- which would be the entry at index (1,end) . That is the meaning I used for "maximum upper triangular matrix".
As you said "embed one bit", that is what I did -- I changed the least significant bit of a particular entry. I did not do any mathematical analysis to figure out whether changing the least significant bit of a floating point number would have any effect when reconstructing the matrix. I would tend to doubt that it would change anything (most of the time) as the absolute value of changing the bit is likely to be only on the order of 10^-13 or so, which is probably not going to matter.
As I have shown you the structure of the program, you can now to change the for idx = 1 : num_watermarkBits loop as appropriate. I show in the code there how to get at the content of one of the blocks; I show how to compute hess(); I show how to modify one bit to a new value, and how to reconstruct the matrix and store it back. You should be able to advance the code from here.
javad danesh
on 14 Feb 2022
Walter Roberson
on 15 Feb 2022
Edited: Walter Roberson
on 15 Feb 2022
h_max__star = h_max - mod(h_max, T) + 0.25*T + 0.5*T*watermarkBits(idx)
... whatever T is here.
Use the two-output form of max(abs(H(:))) to find the element of H that has the largest absolute value
javad danesh
on 15 Feb 2022
Walter Roberson
on 15 Feb 2022
Please stop sending me messages offering to send me the article.
Walter Roberson
on 15 Feb 2022
Telling me that you cannot do the embedding and extraction correctly does not tell me what code you are using, or what problems you are encountering.
The implied message from posting what you posted is that you expect me to read the article and produce a debugged implementation for you, but I am not going to do that. If I have the resources then I will assist you in debugging your code.
javad danesh
on 15 Feb 2022
javad danesh
on 15 Feb 2022
0 votes
11 Comments
Walter Roberson
on 15 Feb 2022
You need to uint8(H_invR) unless you used im2double() when you read it and cover image.
Walter Roberson
on 15 Feb 2022
A challenge in using a random placement of bits when you embed a watermark, is knowing where to look for the bits when you go to extract the bits.
Common strategies include:
- using fixed positions instead of random positions
- using a fixed algorithm for the positions that depends upon the image size
- using a pseudo-random placement with a fixed seed; this is equivalent to using a fixed algorithm that depends on the image size
- using a pseudo-random placement but embed the seed at fixed positions in the image (be careful that noise does not ruin the possibility of retrieving the seed information)
- using the information from all of the other bit planes to compute a seed for pseudo-random placement (again, watch out noise ruining reconstruction by ruining the seed)
If you embed information about how to find the bits into the image, you should be asking yourself what the fewest number of bits is that could be corrupted by noise, that would ruin the possibility to recover the position information.
(It is also a good idea when thinking about watermarks, to ask whether you would still be able to recover the watermark sufficiently well if someone had resized the image and then resized it back... or even just resized the image. Can you recover if the image were to be resized by 50% for example?)
javad danesh
on 15 Feb 2022
Walter Roberson
on 16 Feb 2022
Imagine that you have two neighbors.
One of them says to you, "My car is making a funny noise and I do not understand why".
The other says to you, "This here is my car, and here are my keys in case you need to test it. When I make a left hand turn when I am going more 30 km/hour, there is a scraping noise from the right rear wheelwell area, and the noise goes away about 2 seconds after I straighten the wheel, not immediately; also there is a scraping noise after I go over big bumps."
Imagine that your time is limited. Which of the two are you going to help?
You glance at the car that is sitting right there and you see that it is a 1973 AMC Pacer. You remember that in the early 70s that some of the AMC had defective struts. With the car being that old, it might be a fair bit of work to fix. Or perhaps it is just that the shocks are gone, and that might not be nearly as bad. You have the car right there and you can go for a test drive to narrow down the possibilities.
The other car? "Funny noise" could mean anything from "forgot to take the box off the windshield wiper" to "never had a car with a continuous differential before and that's just how it sounds normally" to "needs a complete engine and engine box replacement". Might be a trivial amount of work, might be a lot of work, you don't know. You do know that when you have asked the neighbor questions before, they seldom give you a straight answer.
You only have time for one of the two. Which one are you going to pick?
javad danesh
on 19 Feb 2022
Edited: javad danesh
on 19 Feb 2022
Walter Roberson
on 19 Feb 2022
You can attach the code here and perhaps someone will have a look at it . Please do not send it to my email.
javad danesh
on 19 Feb 2022
Walter Roberson
on 19 Feb 2022
javad danesh
on 19 Feb 2022
Walter Roberson
on 20 Feb 2022
In that source for pdfbdec, the file lprec.m duplicates lpdec.m . MATLAB does not consider that to be an error, so the program would not give an error unless the calling sequence happened to be incompatible. But without the correct lprec.m I cannot run the program correctly.
javad danesh
on 20 Feb 2022
Categories
Find more on Watermarking in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





