Showing posts with label Matlab. Show all posts
Showing posts with label Matlab. Show all posts

Wednesday, 18 February 2015

Kalman Filter Matlab Code

clc
clear all
close all
warning off

error = 2;
Xnp = [1 2 3 4];
Zn = [1.1 1.9 3 4];
si = length(Xnp);
A = zeros(si,si);
P = zeros(si,si);
Q = zeros(si,si);
H = zeros(si,si);
R = zeros(si,si)*error;
I = zeros(si,si);

for i = 1:si
    A(i,i) = 1;
    P(i,i) = 1;
    H(i,i) = 1;
    R(i,i) = 1;
    I(i,i) = 1;
end

Xn = Xnp*A;
Pn = (A*P*A')+Q;
prevXn = [];
while(true)
    Kk = (Pn*H')*(((H*Pn*H')+R)');
    Xn = Xn+((Zn-(Xn*H))*Kk);
    Pn = (I-(Kk*H))*Pn;
    if(isempty(prevXn))
        prevXn = Xn;
    else
        con = sum(abs(Xn-prevXn));
        if(con==0)
            break;
        end
    end
end

FXn = Xn


Friday, 8 November 2013

Automatic Segmentation of the Pulmonary Lobes From Chest CT Scans Based on Fissures, Vessels, and Bronchi Matlab Code

Abstract


Segmentation of the pulmonary lobes is relevant in clinical practice and particularly challenging for cases with severe diseases or incomplete fissures. In thiswork, an automated segmentation approach is presented that performs a marker-based watershed transformation on computed tomography (CT) scans to subdivide the lungs into lobes. A cost image for the watershed transformation is computed by combining information from fissures, bronchi, and pulmonary vessels. The lobar markers are calculated by an analysis of the automatically labeled bronchial tree. By integration of information from several anatomical structures the segmentation is made robust against incomplete fissures. For evaluation the method was compared to a recently published method on 20 CT scans with no or mild disease. The average distances to the reference segmentation were 0.69, 0.67, and 1.21 mm for the left major, right major, and right minor fissure, respectively. In addition the results were submitted to LOLA11, an international lung lobe segmentation challenge with publically available data including cases with severe diseases. The average distances to the reference for the 55 CT scans provided by LOLA11 were 0.98, 3.97, and 3.09 mm for the left major, right major, and right minor fissure.
Moreover, an analysis of the relation between segmentation quality and fissure completeness showed that the method is robust against incomplete fissures.

Demo



Code Price : 2500 Rs /-
Matlab code is Available..
Contact : ieeematlabcode@gmail.com

Computerized Detection of Lung Nodules by Means of Virtual Dual-Energy Radiography Matlab Code

Abstract


Major challenges in current computer-aided detection (CADe) schemes for nodule detection in chest radiographs (CXRs) are to detect nodules that overlap with ribs and/or clavicles and to reduce the frequent false positives (FPs) caused by ribs. Detection of such nodules by a CADe scheme is very important, because radiologists are likely to miss such subtle nodules. Our purpose in this study was to develop a CADe scheme with improved sensitivity and specificity by use of “virtual dualenergy” (VDE) CXRs where ribs and clavicles are suppressed with massive-training artificial neural networks (MTANNs). To reduce rib-induced FPs and detect nodules overlapping with ribs, we incorporated the VDE technology in our CADe scheme. The VDE technology suppressed rib and clavicle opacities in CXRs while maintaining soft-tissue opacity by use of the MTANN technique that had been trained with real dual-energy imaging. Our scheme
detected nodule candidates on VDE images by use of a morphologic filtering technique. Sixty morphologic and gray-level-based features were extracted from each candidate from both original and VDE CXRs. A nonlinear support vector classifier was employed for classification of the nodule candidates. A publicly available database containing 140 nodules in 140 CXRs and 93 normal CXRs was used for testing our CADe scheme. All nodules were confirmed by computed tomography examinations, and the average size of the nodules was 17.8 mm. Thirty percent (42/140) of the nodules were rated “extremely subtle” or “very subtle” by a radiologist. The original scheme without VDE technology achieved a sensitivity of 78.6% (110/140) with 5 (1165/233) FPs per image. By use of the VDE technology, more nodules overlapping with ribs or clavicles were detected and the sensitivity was improved substantially to 85.0% (119/140) at the same FP rate in a leaveone- out cross-validation test, whereas the FP rate was reduced to 2.5 (583/233) per image at the same sensitivity level as the original CADe scheme obtained (Difference between the specificities of the original and the VDE-based CADe schemes was statistically significant). In particular, the sensitivity of our VDE-based CADe scheme for subtle nodules (66.7% = 28/42) was statistically significantly
higher than that of the original CADe scheme (57.1% = 24/42). Therefore, by use of VDE technology, the sensitivity and specificity of our CADe scheme for detection of nodules, especially subtle nodules, in CXRs were improved substantially.

Demo




Code Price : 3000 Rs /-
Matlab code is Available..
Contact : ieeematlabcode@gmail.com


Splat Feature Classification With Application to Retinal Hemorrhage Detection in Fundus Images Matlab Code

Abstract

A novel splat feature classification method is presented with application to retinal hemorrhage detection in fundus images. Reliable detection of retinal hemorrhages is important in the development of automated screening systems which can be translated into practice. Under our supervised approach, retinal color images are partitioned into nonoverlapping segments covering the entire image. Each segment, i.e., splat, contains pixels with similar color and spatial location. A set of features is extracted from each splat to describe its characteristics relative to its surroundings, employing responses from a variety of filter bank, interactions with neighboring splats, and shape and texture information. An optimal subset of splat features is selected by a filter approach followed by a wrapper approach. A classifier is trained with splat-based expert annotations and evaluated on the publicly available Messidor dataset. An area under the receiver operating characteristic curve of 0.96 is achieved at the splat level and 0.87 at the image level. While we are focused on retinal hemorrhage detection, our approach has potential to be applied to other object detection tasks.

Demo




Code Price : 2500 Rs /-
Matlab code is Available..
Contact : ieeematlabcode@gmail.com

Wednesday, 7 August 2013

Latent Semantic Indexing Matlab Code

In below we give the code of lsi on matlab.



function sim = lsi_calc(A,q,k)

[m,n] = size(A);

[U,S,V] = svds(A,k);

qc = q'*U*inv(S);

for i = 1:n % Loop over all documents

    sim(i) = (qc * V(i,:)') / (norm(qc) * norm(V(i,:)));

end;

Friday, 2 August 2013

Face Detection Matlab Code

Following code used to detect the face.

faceDetection.m



function detectfce = faceDetection(I)



faceDetector = vision.CascadeObjectDetector;  



% Read input image



% Detect faces

bbox = step(faceDetector, I);



% Create a shape inserter object to draw bounding boxes around detections

shapeInserter = vision.ShapeInserter('BorderColor','Custom','CustomBorderColor',[255 255 0]);



% Draw boxes around detected faces and display results             

snapshot0 = step(shapeInserter, I, int32(bbox));   



detectfce = I(bbox(2):bbox(2)+bbox(3),bbox(1):bbox(1)+bbox(4),:,:,:);



Main.m



[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.pgm','All Image Files';...

          '*.*','All Files' },'mytitle');

file = [pathname filename];





FileNames = file;

rgbImage = imread(FileNames);

detectfce = faceDetection(rgbImage );

figure;imshow(detectfce );





Neural Network with hidden Layers Example on Matlab | Matlab Neural Network with 2 hidden Layers

Neural network is one of the artificial intelligence technique,it solve problems in more areas ,like as patter recognition,clustering ,fitting and ect.

Neural network Steps as follow


1.Create the network

2.Train the network



1.Create the network


1st thing we design a network for our inputs for ex we have 2 input and 1 output.

ex:-
>>input = [2 2;4 5;6 7; 7 8; 9 10];
>>output = [1;1;2;2;2];

we create neural network with default hidden layer as follow.

>>net = newff(input,output);


if we want design with users hidden layers then we design as follow.

>>net = newff(input,output,[3 4]);

here [3 4] are two hidden layer. Each layer has each neurons.ex 1st hidden layer has 3 neurons and 2nd one 4 neurons.


2.Train Network


Its train our input data on neural network.

ex:

>>net = train(net,input,output);


Thursday, 25 July 2013

Matlab mex Gcc Configuration on Windows

Matlab mex Gcc Configuration on Windows

Following Steps to Configure Matlab gcc on windows platform.

1. Install Mingw from http://www.mingw.org/ if 64 bit os means , download 64 bit mingw.

2. Install a Cygwin environment http://www.cygwin.com/ if 64 bit os means , download 64 bit cygwin.

3. Download gnumex matlab packages from http://sourceforge.net/projects/gnumex/files/latest/download.

4. Then Extract the gunmex package on your cygwin root folder (ie c:\cygwin folder).

5. The open Matlab and set path to cygwin root folder(ie c:\cygwin).

6. Type gnumex on matlab command window.

7. Then one GUI windows comes.


8. Click Make options file.

9. Done


if shortpath74.mexw32 and uigetpath74.mexw32 problem means please recompile src package's on gumex.

>>mex shortpath.c
>>mex uigetpath.c


if any error means comment in below.

Matlab Wireless Network Simulation code

In below code to simulate a node on Wireless networks.


clc
clear all
close all
warning off

net_width = 10;
net_height = 80;
check = 1;
tot_nodes = 20;
traves_MS = 10;
hT = 4;


% Form Network area....
node_count = 1;
all_x = [];
all_y = [];
for j = 0:9:net_height
    if check==1
        start = 0;
        check = 0;
    else
        start = 5;
        check = 1;
    end
    for i = start:10.3:net_height
        circle([j,i],6,7,'-');
        hold on
        drawnow
        plot(j,i,j,i,'.','color','green');
        nodes(node_count).x = j;
        nodes(node_count).y = i;
        nodes(node_count).id = node_count;
        node_count = node_count+1;
        all_x = [all_x;i];
        all_y = [all_y;j];
    end
end
axis square;

min_x = min(all_x);
max_x = max(all_x);

min_y = min(all_y);
max_y = max(all_y);


% Making Random nodes....
for i = 1:tot_nodes
    x = round(min_x+(max_x-min_x)*rand);
    y = round(min_y+(max_y-min_y)*rand);
    pnt1 = [x y] ;
    best_node_inx = best_dist(pnt1,nodes);
    best_x = nodes(best_node_inx).x;
    best_y = nodes(best_node_inx).y;
    best_pnt = [best_x best_y];
    
    plot(x,y,x,y,'*','color','red');
    all_x = [pnt1(1) best_pnt(1)];
    all_y = [pnt1(2) best_pnt(2)];
    plot(all_x,all_y);
    hold on
    drawnow
end 


% Making Moving Nodes...
s_min_x = min_x+0.5;
s_min_y = min_y+0.5;
con_x = 1;
check = 1;
totms = 0;
traverse_node = [];

station_count = [];
station_data = [];
sel_nodes = [];
last_check_pnt = 1;
while(totms~=traves_MS)
    
    if s_min_x<=max_x&&check == 1
        check = 1;
    else
        check = 0;
        if s_min_x<=min_x && check == 0
            check = 1;
        end
    end
    if check ==1
        s_min_x = s_min_x+1;
        s_min_y = s_min_y+1;
    else
        s_min_x = s_min_x-1;
        s_min_y = s_min_y-1;
    end
    
    
    h1 = plot(s_min_x,s_min_y,s_min_x,s_min_y,'*','color','red');
    pnt1 = [s_min_x s_min_y] ;
    best_node_inx = best_dist(pnt1,nodes);
    best_x = nodes(best_node_inx).x;
    best_y = nodes(best_node_inx).y;
    best_pnt = [best_x best_y];
    hold on
    drawnow
    all_x = [pnt1(1) best_pnt(1)];
    all_y = [pnt1(2) best_pnt(2)];
    h2 = plot(all_x,all_y);
    pause(0.1);
    delete(h1);
    delete(h2);
end


Output


Read Landsat Image on Matlab

Here we give some example for read lan file on matlab.


clc
clear all
close all


file = 'lansetimgfile.lan';


IR1 = multibandread(file, [512, 512, 7], 'uint8=>uint8',...
                    128, 'bil', 'ieee-le', {'Band','Direct',[1]});

IR2 = multibandread(file, [512, 512, 7], 'uint8=>uint8',...
                    128, 'bil', 'ieee-le', {'Band','Direct',[2]});

IR3 = multibandread(file, [512, 512, 7], 'uint8=>uint8',...
                    128, 'bil', 'ieee-le', {'Band','Direct',[3]});

IR4 = multibandread(file, [512, 512, 7], 'uint8=>uint8',...
                    128, 'bil', 'ieee-le', {'Band','Direct',[4]});

IR5 = multibandread(file, [512, 512, 7], 'uint8=>uint8',...
                    128, 'bil', 'ieee-le', {'Band','Direct',[5]});

IR6 = multibandread(file, [512, 512, 7], 'uint8=>uint8',...
                    128, 'bil', 'ieee-le', {'Band','Direct',[6]});

IR7 = multibandread(file, [512, 512, 7], 'uint8=>uint8',...
                    128, 'bil', 'ieee-le', {'Band','Direct',[7]});

figure;imshow(IR);
title('1st Band Image');

figure;imshow(IR);
title('2rd Band Image');

figure;imshow(IR);
title('3rd Band Image');

figure;imshow(IR);
title('4th Band Image');

figure;imshow(IR);
title('5th Band Image');

figure;imshow(IR);
title('6th Band Image');

figure;imshow(IR);
title('7th Band Image');


Related Tags : Matlab code for read lan file, Read Landsat Image matlab code , read lan file in matlab example code.

Image Watermarking Matlab code

Here We Give the code of Image watermarking.


K=8;                                      
Q=50;                                     
W=im2bw(imread('s1.jpg'));                
Mm=size(W,1);                             
Nm=size(W,2);  
  
  
figure(1);  
subplot(321);  
imshow(W);  
title('the orginal watermark');  
  
I=imread('s12.jpg');  
subplot(322);  
imshow(I);  
title('the cover image');  
  
  
II=I;                   % to save the original image(I)  
  
blockrow=Mm;  
blockcol=Nm;  
  
for i=1:blockrow  
    for j=1:blockcol  
        x=(i-1)*K+1;  
        y=(j-1)*K+1;  
        BLOCK=II(x:x+K-1,y:y+K-1);  
        [U,S,V]=svd(double(BLOCK));  
  
        bit=W(i,j);                             %get the one bit wateramrk=bit  
        remainder=rem(S(1,1),Q);  
        if (bit==1)                             %embedding bit '1'  
            if (remainder<=Q/4)  
                S(1,1)=S(1,1)-remainder-Q/4;  
            else   
                S(1,1)=S(1,1)-remainder+3*Q/4;  
            end  
        else                                    %embedding bit '0'  
            if (remainder>=3*Q/4)  
                S(1,1)=S(1,1)-remainder+5*Q/4;  
            else  
                S(1,1)=S(1,1)-remainder+Q/4;  
            end  
        end  
  
        BLOCKW=U*S*V';                    
          
        II(x:x+K-1,y:y+K-1)=uint8(round(BLOCKW));  
          
    end  
end  
  
subplot(324);  
imshow(II);  
title('the watermarked image');  
  
% psnr1=PSNR(I,II)                            
  
A=double(II)-double(I);  
rsm=0;  
for i=1:size(A,1)  
    for j=1:size(A,2)  
        rsm=rsm+A(i,j)*A(i,j);  
    end  
end  
rsm=sqrt(rsm)/(size(A,1)*size(A,2))       
  
% to extracting the wateramrk from image(II)  
for i=1:blockrow  
    for j=1:blockcol  
        x=(i-1)*K+1;  
        y=(j-1)*K+1;  
        BLOCK=II(x:x+K-1,y:y+K-1);  
        [U,S,V]=svd(double(BLOCK));  
          
        remainder=rem(S(1,1),Q);  
        if (remainder>Q/2)  
            EW(i,j)=1;  
        else  
            EW(i,j)=0;  
        end  
    end  
end  
subplot(323);  
imshow(EW);  
title('the extracted wateramrk');  
  
% the watermarked image is attacked   
imwrite(uint8(II),'attack.jpg','jpeg','Quality',70);           %
II1=imread('attack.jpg');  
  

subplot(326);  
imshow(II1);  
title('the attacked image');  
  
for i=1:blockrow  
    for j=1:blockcol  
        x=(i-1)*K+1;  
        y=(j-1)*K+1;  
        BLOCK=II1(x:x+K-1,y:y+K-1);  
        [U,S,V]=svd(double(BLOCK));  
          
        remainder=rem(S(1,1),Q);  
        if (remainder>Q/2)  
            EW(i,j)=1;  
        else  
            EW(i,j)=0;  
        end  
    end  
end  
subplot(325);  
imshow(EW);  
title('the extracted wateramrk');  
  
corr2=NC(double(W),double(EW))              
psnr2=PSNR(I,II1)                           

Matlab Code for Client Server Communication

Server Configuration matlab code

data = 'Hai';
s = whos('data')
tcpipServer = tcpip('0.0.0.0',55000,'NetworkRole','Server');
set(tcpipServer,'OutputBufferSize',s.bytes);
fopen(tcpipServer);
fwrite(tcpipServer,data(:),'char');
fclose(tcpipServer);

Client Configuration matlab code

tcpipClient = tcpip('192.168.1.106',55000,'NetworkRole','Client')
set(tcpipClient,'InputBufferSize',7688);
fopen(tcpipClient);
rawData = fread(tcpipClient,961,'double');
fclose(tcpipClient);

Normalized Cross Correlation ,Normalized Mean Error , RMSE Calculation Matlab Code

Here We give the matlab code for Normalized Cross Correlation ,Normalized Mean Error and RMSE Calculations.

Normalized Cross Correlation matlab code


function NK = NormalizedCrossCorrelation(origImg, distImg)
if size(origImg,3)==1
    origImg = double(origImg);
    distImg = double(distImg);

    NK = sum(sum(origImg .* distImg)) / sum(sum(origImg^2));
else
    r_rm = NormalizedCrossCorrelation(origImg(:,:,1),distImg(:,:,1));
    g_rm = NormalizedCrossCorrelation(origImg(:,:,2),distImg(:,:,2));
    b_rm = NormalizedCrossCorrelation(origImg(:,:,3),distImg(:,:,3));
    NK = (r_rm+g_rm+b_rm)/3; 
end

 NormalizedMeanError matlab code


function NAE = NormalizedMeanError(origImg, distImg)
if size(origImg,3)==1
    origImg = double(origImg);
    distImg = double(distImg);

    error = origImg - distImg;

    NAE = sum(sum(abs(error))) / sum(sum(origImg));
else
    r_rm = NormalizedMeanError(origImg(:,:,1),distImg(:,:,1));
    g_rm = NormalizedMeanError(origImg(:,:,2),distImg(:,:,2));
    b_rm = NormalizedMeanError(origImg(:,:,3),distImg(:,:,3));
    NAE = (r_rm+g_rm+b_rm)/3; 

end


Root Mean Square Error (RMSE) Matlab code


function rmse_val = RMSE_calc(r,f)
if size(r,3)==1
    [m n] = size(r);
    rmse_val = sqrt(sum(double(r(:))-double(f(:))).^2)/(m*n);
else
    r_rm = RMSE_calc(r(:,:,1),f(:,:,1));
    g_rm = RMSE_calc(r(:,:,2),f(:,:,2));
    b_rm = RMSE_calc(r(:,:,3),f(:,:,3));
    rmse_val = (r_rm+g_rm+b_rm)/3;

end

Sunday, 21 July 2013

Matlab Simultaneous Plot

Here we give the sample code for Simultaneous Plot.


t = -pi:pi/300:pi;
axis([-1 1 -1 1 -1 2])
hold on
for i=1:2:length(t)-1
T=[t(i) t(i+1)];
plot3(sin(5*T),cos(3*T),T,'r')
plot3(sin(5*T),sin(3*T),T,'b')
pause(0.000001)
end
hold off

Output


Wednesday, 6 March 2013

Switching Bilateral Filter Noise Removal matlab code

Here we discuss about Switching Bilateral Filter Noise Removal step by step.

1.Read the image pixel by pixel (i,j).
2. Each pixel we construct 4 sub windows.

For a (2N+1) *(2N+1) window we divide the window into four (N+1)*(N+1) subwindows .


case N = 2

3.Find the Sorted Quadrant Median Vector (SQMV) for all subwindows.

SQM1, SQM2, SQM3 and SQM4 are the medians 

4. Then we find the regions from above all SQM.

Uniform Region
Diagonal edge in dark side
Diagonal edge in dark side
Veritical edge
Horizontal edge
Diagonal line
Gradual chage edge 
Texture

5. Then we find the reference median (SQMR)  based on above regions.
6. Then apply Bilateral Filter.
7. The apply noise detection .


Code:

clc
clear all
close all
close all hidden
warning off

con = 1; % con1 for 

img = imread('lena.jpg');

figure;imshow(img);
title('Input Image');


img = imnoise(img,'salt & pepper',0.01); % salt and pepper
Tk1 = 30; % for salt and paper noise..
Tk2 = 15; % for salt and paper noise..


% img = imnoise(img,'gaussian',0,0.01); % gaussian noise
% Tk1 = 25; % for Gaussian noise..
% Tk2 = 5; % for Gaussian noise..


img = double(img);
figure;imshow(uint8(img));
title('Noisy Image');

ext_filt = img;
sigma_R = 40;
[r c] = size(img);
N = 2;
pi_val = 25;
h = waitbar(0,'Applying Switching bilateral filter..');
L = 1;
for i = (N+1):r-(N+1)
    waitbar(L/length((N+1):r-(N+1)));
    L = L+1;
    for j = (N+1):c-(N+1)
        [m0,m1,m2,m3,m4] = meadian_calc(i,j,img,N);
        dav = dav_valc(m1,m2,m3,m4,img,i,j);
        SQMDB = m4-m1;
        SQMDC = m3-m2;
        SQMR = SQMR_calc(SQMDC,m1,m2,m3,m4,dav,pi_val);
        [s1 s2] = find_S1_S2(img,i,j,SQMR,Tk1,Tk2);
        if(dav~=0)
            sigma_S = 3;
        else
            sigma_S = 1;
        end
        f_x_y = f_of_x_y(i,j,N,img,sigma_S,sigma_R,s2,SQMR);
        ext_filt(i,j) = f_x_y;
    end
end
close(h); 

figure;
imshow(uint8(ext_filt));%output...

Referencce : Switching Bilateral Filter With a Texture/Noise Detector for Universal Noise Removal Chih-Hsing Lin, Jia-Shiuan Tsai, and Ching-Te Chiu Transactions on: Image Processing, IEEE Journals 2010

Sunday, 2 December 2012

A New Human Identification Method Sclera Recognition Matlab code

Training
  • Read the all Input Images from Hard Disk Drive Folders.
  • Then Converted RGB into Gray scale Image
  • Applying Horizontal sobel filter on that Image.
  • Estimation of Glare Area.
  • Iris Boundary Detection using circular iris segmentation methods.
  • Extract sclera region using Otsu’s threshold method.
  • Iris and Eyelid Detection and Refinement using Morphological operator and Gabor Filter.
  •  Then Save and create the Iris Eyelid templates on Hard disk Drive.

Testing
  • Read one Image from Hard Disk.
  • Then follow above Training steps 2 to 6 applying.
  • Then mach the Iris Eyelid template on Database template.
  • Finally Recognition Results will Comes.

Output:


System Requirement:

OS : Windows
Matlab  Version : 2012a
Price : Rs 2000
Matlab Code is available.
contact : 8015926919
Email : ieeematlabcode@gmail.com

Monday, 18 June 2012

Matpower Toolbox Examples

Matpower toolbox fully supported for Power System domain.Its solves power flow and optimal power flow in all types of IEEE buses.

you can easy to download from Mathpower Home Page www.pserc.cornell.edu/matpower/. Its open source package .so freely you can download.After downloading you have set the path on Matlab to Matpower toolbox. 

Main Functions(Subroutines)  :

loadcase - > test the loadcase ie(IEEE 14,30,57,118,330 bus system). Its

ex:

loadcase('case14')


totcost -> Test the  total cost of your selected bus systems
ex:
totcost('case14')

uopf ->  Its find the nodal cost of your selected bus system

ex:
uopf('case14')





Saturday, 19 May 2012

RDWT Watermarking matlab code

Watermark Embedding Process

1. Apply RDWT (Redundant DWT) to original image
2.Apply SVD to the LL sub-band of Original image
 
3.Apply RDWT to the watermark image.

4.Apply SVD to the LL Sub-band of watermark image

5.Modify the singular values of the original image with the singular values of the watermark image

6.Apply inverse SVD on the transformed original image with modified singular values.

7.Apply inverse RDWT to obtain the watermarked image.

 Watermark Extraction Process

 1.Apply RDWT on the watermarked image.
2.Apply SVD to the LL sub-band of the watermarked image.
3.Extract the singular values of watermark image from the singular values of watermarked image and original image.

4.Apply inverse SVD
5.Apply inverse RDWT to obtain the watermark image.



Matlab code is given below


Embedding



clc
clear all
close all
warning off
alpha = 0.25;
input_img = imread('lena512.bmp'); % read input image
[LL,LH,HL,HH] = dwt2(input_img,'haar','mode','sym'); % applying  redundant DWT
[I_u,I_s,I_v] = svd(LL); % extract sigular values...
water_img = imread('cameraman.bmp'); % read watermark image
[WLL,WLH,WHL,WHH] = dwt2(water_img,'haar','mode','sym'); % applying  redundant DWT
[W_u,W_s,W_v] = svd(WLL); % extract sigular values...
S_n = I_s + (alpha*W_s); %Watermark Embedding
new_LL = I_u*S_n*I_v'; %Watermarked Image Construction
new_img = idwt2(new_LL,LH,HL,HH,'haar','mode','sym');
new_img=uint8(new_img);
imwrite(new_img,'Watermarked.bmp');


Extraction



clc
clear all
close all
warning off
alpha = 0.25;
water_img = imread('Watermarked.bmp'); % read watermarked image
[WMLL,WMLH,WMHL,WMHH] = dwt2(water_img,'haar','mode','sym'); % applying  redundant DWT
[Wm_u,Wm_s,Wm_v] = svd(WMLL); % extract sigular values...
input_img = imread('lena512.bmp'); % read input image
[LL,LH,HL,HH] = dwt2(input_img,'haar','mode','sym'); % applying  redundant DWT
[I_u,I_s,I_v] = svd(LL); % extract sigular values...
S_w= (Wm_s-I_s)/alpha; % Watermark extraction
watermark=imread('cameraman.bmp');
[WLL,WLH,WHL,WHH] = dwt2(watermark,'haar','mode','sym'); % applying  redundant DWT
[W_u,W_s,W_v] = svd(WLL); % extract sigular values...
new_WLL=W_u*S_w*W_v';
Watermark_img=idwt2(new_WLL,WLH,WHL,WHH,'haar','mode','sym');
Watermark_img=uint8(Watermark_img);
imwrite(Watermark_img, 'Watermark_img.bmp');


Related Search: Watermarking matlab code , Digital Watermarking RDWT matlab code ,SVD based Watermarking matlab code.Matlab watermark embedding and extraction.

Matlab Neural Network Watermarking Code

 Watermark Embedding
  1. Divide the original image I into blocks of size 8X8 and perform three-level DWT transform on each block. Select the position of watermark embedding coefficient using random sequence with a secret key and quantize the DWT coefficient C(I,j) by Q and use that value as the input T of BPN.
  2. Create the improved neural network and initialize its parameters, we use T as the supervised signal and the average of each block is used as the desired output value of the BPN to train BPN. Training error is set to be 0.001.
  3. Perform the inverse discrete wavelet transform (IDWT) on the coefficients where the watermark is embedded to obtain the watermarked image.
Watermark Extraction

  1. Perform the three-level DWT transformation on the watermarked image blocks.
  2. Select the position of coefficient C(i, j), where watermark is embedded with the same secret key , which is used in watermark embedding sequence.
  3. Quantize the DWT coefficient by Q, and use it as input value of the trained BPN to get the output T.
  4. Extract the watermark according to (6) below using the output T and coefficient C(i ,j)

Sunday, 13 May 2012

Matlab Automatic Vehicle Plate Recognition code

Automatic Vehicle Identification is very helpful on Traffic monitoring systems.Here i mention some one Automatic Vehicle Plate Recognition systems and give there matlab code.Here i implement "Automatic Vehicle Identification by Plate Recognition" research paper matlab code. This research paper do followings operations.

  1. Read input image.
  2. Converted into Binary image.
  3. Then threshold based area removal using smearing algorithms.
  4. Applying Morphological dilation and extract Plate area.
  5. Finally apply segmentation to extract the characters.
 Matlab code and output as given below.

clc
clear all
close all
warning off

in_img = imread('input.JPG');
figure;imshow(in_img);
% Threshold based car parts removing...

bw_img = im2bw(in_img);
% imshow(bw_img);

hori_thresh = sum(bw_img,2);


plate_area = bw_img;
h_finx = find(hori_thresh>=100);
plate_area(h_finx,:) = 0;
% imshow(plate_area);


ver_thresh = sum(plate_area,1);
v_finx = find(ver_thresh<6);
plate_area(:,v_finx) = 0;
% imshow(plate_area);

% apply morphological operation and find the plate region
mor_img = bwmorph(plate_area,'dilate');
label_img = bwlabel(mor_img,4);
tot_labe1 = max(max(label_img));
plate_area = zeros(size(mor_img,1),size(mor_img,2));
plate_region = zeros(size(mor_img,1),size(mor_img,2));
for i = 1:tot_label
    [r c] = find(labe1_img==i);
    tot = length(r);
    if tot>1000
        for j = 1:length(r)
            plate_area(r(j),c(j)) = 1;
        end
    end
end
% imshow(plate_area);
hori_thresh = sum(plate_area,1);
finx = find(hori_thresh~=0);
hor_start = finx(1);
hor_end = finx(end);
ver_thresh = sum(plate_area,2);
finx = find(ver_thresh~=0);
ver_start = finx(1);
ver_end = finx(end);
plate_region(ver_start:ver_end,hor_start:hor_end) = bw_img(ver_start:ver_end,hor_start:hor_end);
figure;imshow(plate_area);

% Plate extraction...
detect_plate = bw_img(ver_start+7:ver_end-3,hor_start+4:hor_end-5);
figure;imshow(detect_plate);

char_vals = sum(detect_plate,1);


Output


Related Search : Matlab Automatic Vehicle Plate Recognition code , Extraction of license plate from vehicle matlab code,Vehicle number plate recognition(VNPR) matlab code
Related Posts Plugin for WordPress, Blogger...