بخش 10آموزش برنامه نویسی درنرم افزار متلب
در این بخش میخوانیم :
1- تابع Laplacian یک تقریب از مشتق مرتبه 2
2- فرمول مشتق
3- مشتق گیری دو بعدی
4- فیلتر Log
Clc; Clear ; Close all ; Img 0 = imread ( ‘ rice . png ‘ ) ; Alpha 1 = 0 ; W1 = fspecial ( ‘ laplacian ‘ , alpha 1 ) ; Img 1 = imfilter ( img 0 , w1 , ‘ circular ‘ ) ; Alpha 2 = 0 . 2 ; W2 = fspecial ( ‘ laplacian ‘ , alpha 2 ) ; Img 2 = imfilter ( img 0 , w2 , ‘ circular ‘ ) ; Alpha 3 = 0 . 4 ; W3 = fspecial ( ‘ laplacian ‘ , alpha 3 ) ; Img 3 = imfilter ( img 0 , w3 , ‘ circular ‘ ) ; Alpha 4 = 0 . 8 ; W4 = fspecial ( ‘ laplacian ‘ , alpha 4 ) ; Img 4 = imfilter ( img 0 , w4 , ‘ circular ‘ ) ; Alpha5= 1 ; W5 = fspecial ( ‘ laplacian ‘ , alpha 5 ) ; Img 5 = imfilter ( img 0 , w5 , ‘ circular ‘ ) ; Figure ; Subplot (2, 3 , 1 ) ; Imshow ( img 0 ) ; Title ( ‘ Original Image ‘ ) ; Subplot (2, 3 , 2 ) ; Imshow ( img 1 ) ; Title ( [ ‘ Laplacian with / alpha = num 2 str(alpha 1 ) ] ) ; Subplot (2, 3 ,3) ; Imshow ( img 2 ) ; Title ( [ ‘ Laplacian with \ alpha = num 2 str(alpha 2 ) ] ) ; Subplot (2, 3 , 4) ; Imshow ( img 3 ) ; Title ( [ ‘ Laplacian with\ alpha = num 2 str(alpha 3 ) ] ) ; Subplot (2, 3 , 5) ; Imshow ( img 4 ) ; Title ( [ ‘ Laplacian with \ alpha = num 2 str(alpha 4 ) ] ) ; Subplot (2, 3 ,6) ; Imshow ( img 5 ) ; Title ( [ ‘ Laplacian with\alpha = num 2 str(alpha5) ] ) ;
Functhon Xn = Normalize ( X , beta )
If nargin < 2 Beta = 1 ; End X min = min ( x ( : ) ) ; X max = max ( x ( : ) ) ; XN = ( ( X – X min ) / ( X max – X min ) ) . ^ beta ;
Clc; Clear ; Close all ; Img 0 = imread ( ‘ rice . png ‘ ) ; Img 0 = im2double ( img 0 ) ; Alpha = 0 ; W = fspecial ( ‘ laplacian ‘ , alpha ) ; Img 1 = imfilter ( img 0 , w , ‘ circular ‘ ) ; C = -1 ; Img 2 = img 0 + c * img 1 ; Figure ; Subplot ( 1 , 3 , 1 ) ; Imshow ( img 0 ) ; Title ( ‘ Original Image ‘ ) ; Subplot ( 1 , 3 , 2) ; Imshow ( img 1 ) ; Title ([ ‘ Laplacian with \ alpha = ‘ num2str ( alpha) ] ) ; Subplot ( 1 , 3 , 3 ) ; Imshow ( img 2 ) ; Title ( ‘ Image Enhancement with Laplacian ‘ ) ;
Clc; Clear ; Close all ; Img 1 = imread ( ‘ rice . png ‘ ) ; Sigma = 1 ; W = fspecial ( ‘ Log ‘ , 5 , sigma ); >> w = fspecial ( ‘ Log ‘ , 100 ) ; >> w = w / max ( w ( : ) ) ; >> imshow ( w )
>> w = fspecial ( ‘ Log ‘ , 100 , 10 ) ; >> w = w / max ( w ( : ) ) ; >> imshow ( w )
>> w = Normalize ( w ) ; >> imshow ( w )
Clc; Clear ; Close all ; Img 0 = imread ( ‘ rice . png ‘ ) ; Img 0 = im2double ( img 0 ) ; W = fspecial ( ‘ motion ‘ , 40 , 45 ) ; Img = imfilter ( img 0 , w ,’circular ‘ ) ; Figure ; Subplot ( 1 , 2,1) ; Imshow ( img 0 ) ; Title ( ‘ Original Image ‘) ; Subplot ( 1 , 2,2) ; Imshow ( img 1 ) ; Title ( ‘ After Motion Filter ‘ ) ;
ادامه آموزش متلب در بخش 11