>> help circle
circle.m not found.
Use the Help browser Search tab to search the documentation, or
type "help help" for help command options, such as help for methods.
หมายความว่า circle ไม่มีใน MATLAB
--------------------------------------------------------
การสร้างฟังก์ชั่นใช้งานในMATLAB
function y = circle(x)
%circle is the function use for circle area computation
%y is circle area
%x is radius
y = pi*(x*x);
Save ในชื่อ circle.m
ที Current Directory ให้เป็นตำแหน่งเดียวกันโฟลเดอร์ที่เซฟ circle.m ไว้
ใน command Window
>> help circle ก่อนทำการสร้างฟังก์ชั่น
circle.m not found.
Use the Help browser Search tab to search the documentation, or
type "help help" for help command options, such as help for methods.
>> help circle หลังทำการสร้างฟังก์ชั่น
circle is the function use for circle area computation
y is circle area
x is radius
------------------------------------------------------------------
EX
a = imread('ngc6543a.jpg'); //โหลดภาพเข้ามา
a=rgb2gray(a); //เปลี่ยนภาพสีเป็นสีเทา
imshow(a)
x = imhist(a); //สร้างกราฟฮิสโตแกรมจากูปภาพ
figure,plot(x) // โชว์กราฟ
corr2 (x,x) // ฟังก์ชั่นเปรียบเทียบ
ans =
1
-----------------------------------------------------------------
JOBเปรียบเทียบรูป
//โหลดรูปเข้ามาและเปลี่ยนเป็นโทนสีเทา
x1 = imread('C:\Users\Guest\Desktop\Flower\1.jpg');
x1=rgb2gray(x1);
x2 = imread('C:\Users\Guest\Desktop\Flower\2.jpg');
x2=rgb2gray(x2);
imshow(x2)
x2 = imread('C:\Users\Guest\Desktop\Flower\2.jpg');
x2=rgb2gray(x2);
x3 = imread('C:\Users\Guest\Desktop\Flower\3.jpg');
x3=rgb2gray(x3);
x4 = imread('C:\Users\Guest\Desktop\Flower\4.jpg');
x4=rgb2gray(x4);
x5 = imread('C:\Users\Guest\Desktop\Flower\5.jpg');
x5=rgb2gray(x5);
x6 = imread('C:\Users\Guest\Desktop\Flower\6.jpg');
x7 = imread('C:\Users\Guest\Desktop\Flower\7.jpg');
x8 = imread('C:\Users\Guest\Desktop\Flower\8.jpg');
x9 = imread('C:\Users\Guest\Desktop\Flower\9.jpg');
x6=rgb2gray(x6);
x7=rgb2gray(x7);
x8=rgb2gray(x8);
x9=rgb2gray(x9);
//สร้างกราฟฮิสโตแกรมจากรูปเทาดำ
h1=imhist(x1);
h2=imhist(x2);
h3=imhist(x3);
h4=imhist(x4);
h5=imhist(x5);
h6=imhist(x6);
h7=imhist(x7);
h8=imhist(x8);
h9=imhist(x9);
//สร้างฟังก์ชั่น SAD หาความแตกต่างของรูป โดยเซฟเป็น m-file
function z=SAD(his1,his2)
sum = 0;
for i=1:256
sum=sum+abs(his1(i)-his2(i));
end
z=sum;
end
//ยังไม่เสร็จ สร้างเมทริกเก็นค่าเปรียบเทียบทั้ง 9 รูป แล้วหาที่น้อยสุดยกเว้น 0 คือรูปที่คล้ายกันที่สุด
ค่าที่มากสุด คือรูปที่ต่างกันมากที่สุด
//การบ้านส่งปลายเทอม