You are on page 1of 7

MatLab Code Update for Optimization V.

2
Image Analysis Project: Goal to update the V.1 code so that we can optimize the watermarking process for embedding 1 or 2 watermarks in the finger print image. 1. First, make changes to the code so that some steps of the water-marking process (embedding and extraction) can be treated as variable which can be first initialized and then changed or optimized during the optimization loop as according to PSO and GA loops described below. Following are the variables to be optimized automatically in a loop for a finger-print image of size 512x512: a. b. c. d. Gain factor k Threshold factor t Which level we use for embedding the sub-band Which sub-band coefficients or mixture of sub-band coefficients we embed the image in the chosen or given level e. Use the specified full sub-band or just part of a sub-band f. Size of the water-mark image (p x q) in relation to the size (512x512) of the finger print image g. Embed 1 watermark or 2 or more watermark images in the chosen sub-band bands As an example: For a 2-level DWT process we get 2-level sub-bands You will get the two level sub-bands as according to the following figure

The sub-band (LH1, HL1, HH1) is the high frequency sub-band The sub-band (LH2, HL2, HH2) is the medium frequency sub-band The sub-band LL2 is the low or lowest frequency sub-band which will not be used for embedding The DWT transformed image of size ( N x N ) has been transformed into r ( N/r x N/r) images for different sub-bands In level 1: Do we embed the image only in HH1, or HL1, or LH1 or a combination of them? Or In Level 2:

Again we embed the image only in HH2, or HL2, or LH2 or a combination of them? Or Can we split the image and use a combination HH1 and HH2? Let us say: we thus have a list of 6-7 variables or parameters to be optimized using an optimization loop. Based on our current knowledge of the process we specify an initial range in which each of these variable would be allowed to vary. The many initial set of parameters is randomly chosen within the chosen ranges. Each set of parameter values is called a particle. Therefore many sets of the chosen parameter values forms a population of particles If during the simulation, any parameter or variable starts hitting the boundary of the chosen range, we can increase that range by moving that boundary further out and also check why is that happening or is that reasonable or not etc? 2. Now, the Particle Swarm Optimization (PSO) loop We randomly choose a population of particles (many initial set of variables or parameters), and run the optimization loop by the following updates. The PSO equations (positions Xi and velocities Vi ) for a particle i in a chosen population are:

Where N are the total number of variables or parameters we are trying to optimize. For the chosen population for each particle (i) (ii) (iii) We run the DWT process for watermarking Compute the fitness function (explained below) And select the minimum value of the computed fitness functions, which we are trying to minimize as a part of the optimization procedure, as the best particle so far in the chosen population.

Then the positions and velocities vectors (Xi ,Vi) of each particle for the next step (n+1) are updated as according to the following step.

Where Xibest and Xbest are the individual best (for each particle) and global best (thus for for the simulated set) values, respectively. It is easy to guess that at the 1st step n = 0,

the 1st term in Eq. 3 is zero, and 2nd and 3rd term are non-zero for all the particles except the best particle at the first step, for which the velocity is zero. The position of the best particle is not updated and all other particles are updated to n +1 as according to Eq.4.This way, at each step the solution preserves the locally best and globally best values as according to Eq.3-4 until a convergence is reached and fitness function is minimized. The flow chart of the optimization loop is from Fig.1:

3. Fitness function: We can start with the simplest fitness function: Fitness Function:

Where PSNR and SSIM for a DWT watermarking with a given particle are explained as according to: As mentioned above, the key metrics of the quality are the peak signal to noise ratio (PSNR) and Structural Similarity Index Metric (SSIM). The PSNR is the ratio of the pixel intensity

between the initial image and the watermarked image measured in decibel (db). For an initial image I of size N M and its watermarked image Iw, PSNR is given by:

(1)

where is the maximum signal value that exist in the original image, and Mean Square Error as according to,

is the

(2)

The SSIM metric is related with the perceptibility of the human vision system (HVS), it is defined by:

(3)

Where and w are the mean luminance of the original and watermark images I and Iw, respectively. The and are the standard deviations of the and respectively, and C1 and C2 are the constants to avoid the singularity in the above expression. In practice, the mean SSIM (MSSIM) is computed over many sliding windows across the image to access the overall quality of the image.

Which means, that at each optimization step: For a given population For variables or parameters for each particle in the given population DWT watermarking is done And PSNR and SSIM and computed from the original and watermarked image And fitness-function is computed as according to the above And the loop is updated according to the flow chart and the equations in 2 Finally the best particle is chosen which gives the minimized value of the fitness function

Produce 1st results on side by side comparison of the original finger-print image, the texture map of the finger print image, and the selected high texture regions of the finger print image for embedding as according to the above

4. Now do the embedding as according to the following flow chart:

Where secret key will be the seed of random number sequence generated for embedding IDWT is the two level inverse DWT transform to get the Watermark fingerprint image 5. Embedding algorithm for the input facial image The grey scale values of the facial image is considered as L, I, and M representing the least, intermediate, and the most significant integer values of the face image water mark wf of size (pxq) as according to

Thus the least, intermediate, and most significant integer values of the facial watermark image are embedded in the LH2, HL2, and HH2 frequency sub-bands, respectively. 6. Embedding the Text Image: The text image wt of size (r x s) is embedded into the regions HH1,LH1, and HL1 by replacing the lowest order significant integers in these sub-bands with the text water-mark bits as according to:

7. Finally getting the watermarked image with two watermark image as according to the flow chart shown above: Simply do inverse two-level wavelet transform (IDWT) to reconstruct the image sub-bands Secret key would be the seed of a random number sequence generator use to randomly select the embedding locations (i , j) on the image. A strength or amplifying factor is selected to maximize the correlation between the original watermark and the embedded watermark. This is done as an iterative optimization procedure. This is done by computing the difference between the embedded watermark and the original watermark and kept that difference to a minimum or within a targeted low value as according to: = wm / we where wm and we are the original and embedded watermarks, respectively. Result 2: Show and compare the original finger print image and the two watermarked fingerprint images side by side 8. Finally the extraction of the two watermarks

The flow chart of the extraction of the two watermarked images is:

The extraction process is the reverse of the embedding process The same secret key is used to generate the same sequence of random number generator to again locate the locations where bits of the two water marks and embedded The selected texture regions of all six sub images (used for embedding) is again computed as according to the above in steps 6 and 7, and the bits for watermarks are extracted from the lowest order integer in the corresponding sub-band images. For facial image extraction all the three image sub-bands HH2, HL2, and LH2 are used Where as for text image extraction, there is redundancy in the image sub-bands HH1, HL1, LH1, therefore any one (preferably HH1) could be used for the extraction. Result 3: Extract the two watermark images and compare them side by side with the original two watermark images to check the quality. Over all, there are three input images given to the working code and three result outputs should come out of the code.

You might also like