Posts

Example for simple function with two parameters in matlab

%Let us discuss the function with two paramaters with simple example %We know the formula for the volume of a cone is p*(1/3)*r^2*h conevolmain.m clc; clear all; radius = input('Enter the radus of the cone:'); height = input('Enter the height of the cone:'); cv=conevol(radius,height); fprintf('Volume of the cone with radius %.1f \n and with height %.1f', radius,height); fprintf('\n is:  %.2f'\n,cv); conevol.m function out=conevol(radius,height) out=(pi/3)*radius^2*height; end output: Enter the radus of the cone:5.6 Enter the height of the cone:6 Volume of the cone with radius 5.6  and with height 6.0  is:  197.04

Example for the simple function in Matlab

%Let us discuss functions in Matlab with the simple example % We know the formula for area of the circle is a=pi * r^2. %Let  us write a function for this. areacircmain.m clc; clear all; radius = input('Enter the radus of the circle:'); ac=areacir(radius); fprintf('Area of the circle with radius %.1f is %.1f\n', radius,ac); areacir.m function out=areacir(radius) out=pi*radius^2; end output: Enter the radus of the circle:5.2 Area of the circle with radius 5.2 is 84.9

To find the MSE value

%Let me explain with the same example. %To the input image Iimg applied the 'Salt & Pepper noise' with the noise ratio of 20% and named as 'Nimg'. %Now for the 'Nimg' i applied median filter and named as Mimg. %Now i need to find the 'Mean Square Error' MSE comparison between Mimg and Nimg. clear all close all clc; Iimg=imread('moon.tif'); [r c]=size(  Iimg ); d=ndims( Iimg ); if d == 3      Iimg =rgb2gray( Iimg ); end Iimg=double( Iimg ); Iimg= Iimg /225; Nimg=imnoise( Iimg ,'salt & pepper',0.2); Mimg=medfilt2( Nimg ,[5 5]); clc; Diff= Nimg - Mimg ; MSE= sum(sum(Diff.* Diff)) / (r * c); fprintf('\n\nThe Mse value is:  %d',MSE1); subplot(1,2,1);imshow( Nimg );title('Noised image'); subplot(1,2,2);imshow( Mimg );title('Denoised image'); RESULT: The Mse value is:  2.521604e-002 i.e, MSE ~ 0.0252

To find the PSNR Value for the denoised image

Image
%Let me explain with an example. %To the input image Iimg applied the 'Salt & Pepper noise' with the noise ratio of 20% and named as 'Nimg'. %Now for the 'Nimg' i applied median filter and named as Mimg. %Now i need to find the 'Peak signal noise ratio' PSNR comparison between Mimg and Nimg. clear all close all clc; Iimg =imread('Moon.tif'); [r c]=size( Iimg  ); d=ndims( Iimg  ); if d == 3      Iimg  =rgb2gray( Iimg  ); end Iimg =double( Iimg  ); Iimg = Iimg  /225; Nimg=imnoise( Iimg   ,'salt & pepper',0.2); Mimg =medfilt2( Nimg ,[5 5]); imshow( Mimg  ); clc; fprintf('\n\n###  The PSNR value  ###\n\n') PSNR( Nimg , Mimg  ); subplot(1,2,1);imshow(Nimg);title('Noised image'); subplot(1,2,2);imshow(Mimg);title('Denoised image'); Moon.tif: RESULT: ###  The PSNR value  ### PSNR = +11.21 dB

Matlab code to get negative of an image

Image
clear all; clc; close all; OriImg=imread('lena.tif'); %This will reads the image to i NegImg=imcomplement(OriImg); %This will moves complement of image i into y %The below statements will produce the output subplot(1,2,1);imshow(OriImg);title('Original image'); subplot(1,2,2);imshow(NegImg);title('Negative image'); RESULT:

What is a digital image?

Image
As we know Image may be defined as 2-dimensional intensity function f(x,y) where x,y are the spatial coordinates.      But let us discuss apart from book. A 2-D image is nothing but a 2-D matrix. I think we all are familiar with the word Matrix . In matrix, each intersection of row and column is nothing but Cell . But where as in images we can simply say it as Pixel , that is what we discussed before.      For any matrix it bears a number at-least '0' ( ofcourse zero makes a vast difference during the processing of the images ), which we called it as Value . But in images it is called it as Intensity values .       You are well familiar with Intensity value. Now i want to show you a diagram to explain about the brightness of the pixels in the image for each intensity values. Changes in the colors at different grey percentages      From the above chart we can simply recognize the change in the color, which is inversely proportional to the percentage of gray levels. (

The link is the website for Image processing, which may helpful for the new commers

If you want to jump from here to image processing place webpage click the below link. click here /