Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Digital Image Water Marking – Part 1


Digital image watermarking is the method in which data is embedded in a multimedia file such as an image or a video, so as to verify the credibility of the content or the identity of the owner.

MATLAB CODE:
%Digital Image Watermarking

%Unmasked Image f
f = imread('angel.jpg');
figure,imshow(f);title('Unmasked Image');
 
Unmasked Image
%Watermark
w = imread('watermark_sym.jpg');
figure,imshow(w);title('Watermark');







%Visibility of the watermark
alpha=0.5;

Fw = (1-alpha)*f + alpha.*w;
figure,imshow(Fw);title('Watermarked Image-Visibilty:0.5');



Explanation:
1.      Read the image to be watermarked. In my case it ‘s ‘angel.jpg’
2.      Read the watermark. Make sure the image size and the watermark size are same.
3.      Adjust the alpha value based on your requirement. Alpha can be between 0 and 1. If alpha is less than 0.5 the watermark will be less visible and if the alpha is more than 0.5, the watermark will be clearly visible.



MATLAB CODE:

%Read the Blog logo
Logo = imread('Dwatermark2.jpg');
figure,imshow(Logo);title('Blog Logo');


OIm = f;
%Visibility control
alpha = 0.5;

[m, n,~]=size(Logo);

%choose a portion of the Image
Sz = [495 927];

%Apply watermark
OIm(Sz(1):Sz(1)+m-1,Sz(2):Sz(2)+n-1,:)=(1-alpha)*OIm(Sz(1):Sz(1)+m-1,Sz(2):Sz(2)+n-1,:) + alpha.*Logo;
figure,imshow(OIm);title('Watermark in the centre');



EXPLANATION:
1.      Read the blog logo.
2.      Note: The size of the input image and the logo are not same.
3.      Choose a portion in the input image and apply watermark.



LSB Digital Watermarking
In this method, the watermark is hidden in the input image.
Consider a pixel from the input image; say 249 and a pixel from the watermark say, 155.
Now hide the pixel value of the watermark in the two least significant bits of the input image.
1.      The binary representation of 249 is 11111001
2.      The binary representation of 155 is 10011011
3.      Make the two least significant bits of input image value 249 to zeros i.e. 11111000
4.      Find the two Most significant bits of the watermark value 155 i.e. 10
5.      Now place the two most significant bits of the watermark at the two least significant bits of the input image.
6.      11111000 + 00000010 = 11111010 i.e.  250


MATLAB CODE:
%LSB watermarked Image
Fw1 = 4*(f/4) + w/64;
figure,imshow(Fw1);title('LSB watermarked Image');




How to retrieve the watermark:
Method 1:
Subtract the input image (without watermark) from the watermarked Image.
%Retrieve the Watermark
DMark = (Fw1-f)*64;
figure,imshow(DMark);title('Watermark extracted from the image');



Method 2:
Retrieve the two least significant bits of the image
%Retrieve the Watermark
DMark2 = rem(Fw1,4)*64;
figure,imshow(DMark2);title('Watermark extracted from the image');

We can extend the above techniques for steganography or image coding. In the next upcoming post I will share about how to validate the digital watermark.





like button Like "IMAGE PROCESSING" page

Image Zooming – Part 1


Let’s try to view an Image of size 1366 x 768.
To view the image:
I = imread('Vatican-City-Wallpaper_.jpg');
figure,imshow(I);
Reference:
The image is too big. I want to view the image part by part, so that I can view the details in the image more clearly.


Method one:
I use MATLAB function ‘imshow’ and the ‘figure’ command.
To view the image:
I = imread('Vatican-City-Wallpaper_jpg');
figure,imshow(I);

Now click the ‘zoom in’ option to enlarge the image.
ZOOM IN


Click the ‘pan’ option and drag the cursor to view the image part by part.
 
PAN OPTION

Method two:
We can do the image viewing using our own code instead of using ‘zoom in’ and ‘pan’ options.
We will define our own window and display the image alone.
%Read the Image
I=imread('Vatican-City-Wallpaper_.jpg');
Im=I;


%Get the Screen size and define the window
scrsz = get(0,'ScreenSize');
figure('Position',[300 50 scrsz(3)-600 scrsz(4)-200],'Menu','none','NumberTitle','off','Name','VIEW PHOTO','Resize','off');

%Size of the Image Portion
Len=round(size(I,1)/4);
Flag=1;
x=1;
wid=Len;
y=1;
ht=Len;

%Display the image
ax=axes('Position',[0 .1 1 .8],'xtick',[],'ytick',[]);
imshow(Im(x:wid,y:ht,:));

Num=50;
while(Flag==1)
try
    %User button click
    waitforbuttonpress;
    pt=get(ax,'CurrentPoint');
    y1=round(pt(1,1));
    x1=round(pt(1,2));
   
    %Calculate the Next part of the image based on the button press
    if( x1 < Len && x1 > 0 && y1 < Len && y1 > 0)
   
    x=x+x1;
    y=y+y1;
    if(x-Num>1)
      
        x=x-Num;
    end
   
    if(y-Num>1)
      
        y=y-Num;
    end
   
    if(x+wid>size(I,1))
      
        x=size(I,1)-wid;
    end
   
    if(y+ht>size(I,2))
      
        y=size(I,2)-ht;
    end
   %New Image Part
   imshow(Im(x:x+wid,y:y+ht,:));
  
   wid=Len;
   ht=Len;
  
    end
catch
    Flag=0;
end

end

 
Click on the bottom right part of the image to view the center part

Click to the right from the above mentioned part 
like button Like "IMAGE PROCESSING" page
Previous Post Next Post Home
Google ping Hypersmash.com