SlideShare a Scribd company logo
1 of 22
Download to read offline
การใช้โปรแกรมMATLAP
โปรแกรมนี้จะง่ายกว่าการเขียนภาษา C เนื่องจากไม่ต้องเขียนโค้ดหลายๆบรรทัด
เขียนคาสั่งได้เลย
, คือ การแบ่งตัวเลขออกจากกัน ถ้าไม่ใส่ , โปรแกรมจะเข้าใจว่าเป็นเลขตัวเดียวกัน
; คือ คาสังให้ขึ้นบรรทัดใหม่
ถ้าเขียนโค้ดผิด แต่ enter ไปแล้วจะไม่สามารถแก้ไขได้อีก ให้เขียนโค้ดใหม่ขึ้นมา
แทนได้เลย
 การนับแบบเรียงค่า
ค่าเริ่มต้น : ค่าสุดท้าย
ค่าเริ่มต้น : นับทีละเท่าไร : ค่าสุดท้าย
การ plot graph
 การ plot กราฟ
กราฟนี้ใช้ค่า x = 0 3 6 9 12 15 18 ตามที่เคยกาหนดไว้
กาหนดค่า x เพื่อให้กราฟมีความแตกต่างอย่าเห็นได้ชัด
 การเปลี่ยนลักษณะกราฟ
Plot (x, ‘สี เส้น ลักษณะพิกัด’)
1.Plot (x, ‘--bs’) 2. Plot (x, ‘b--o’)
3. Plot (x, ‘c*’) 4. Plot (x, ‘c--*’) 6. Plot (x, ‘y--*’)
 การทาเครื่องคิดเลข
เลือก Push Button เพื่อสร้างช่องสาหรับแสดง
ผลลัพธ์และช่องสาหรับปุ่มเครื่องคิดเลข
สาหรับเปลี่ยนสีพื้นหลัง ตั้งชื่อกรอบ และแก้ไขกรอบ
สร้าง 4 แถว 5 คอลัม
เลือก Push Button เพื่อสร้างปุ่มตัวเลขและ
เครื่องหมาย
*ทาแบบนี้ทั้งตัวเลขและเครื่องหมาย
ใส่ 0 ตรง String
ใส่ zero ตรง Text box
พิมพ์code เพื่อให้เลขปรากฏในช่อง input
str=get(handles.input,'String');
str=strcat(str,'0');
set(handles.input,'String',str);
คลิกขวาที่ช่องตัวเลข เลือก View Callbacks
เลือก Callback เพื่อที่จะเขียน code ให้เลข
หรือเครื่องหมายนั้นสามารถใช้งานได้
กด Run เพื่อทดสอบว่ากดเลข 0 แล้วจะแสดงในช่องinputหรือไม่ ถ้าเลข 0 สามารถ
แสดงในช่อง input ก็ให้ทาการ
Coppy code อันเดิมแล้วเปลี่ยนจากเลข “0” เป็นเลขอื่นๆของแต่ละฟังก์ชั่น ทาไป
เรื่อยๆ ตั้งแต่ 0-9 และเครื่องหมาย - + X / แล้วทาการทดสอบอีกครั้งเพื่อดูว่าตัวเลข
สามารถใช้งานได้ทุกตัวหรือไม่
พิมพ์code เพื่อใช้ฟังก์ชั่น +/-
str=get(handles.input,'String');
s=str2double(str);
e=-(s);
t=num2str(e);
set(handles.input,'String',t);
พิมพ์codeเพื่อใช้ฟังชั่นสแควรูท
str=get(handles.input,'String');
s=str2double(str);
sqr=sqrt(s);
t=num2str(sqr);
set(handles.result,'String',t);
พิมพ์code เพื่อใช้ฟังชั่น %
str=get(handles.input,'String');
s=str2double(str);
per=s/100;
t=num2str(per);
set(handles.result,'String',t);
พิมพ์code เพื่อใช้ฟังชั่น 1/X
str=get(handles.input,'String');
s=str2double(str);
div=(1/s);
t=num2str(div);
set(handles.result,'String',t);
พิมพ์code เพื่อใช้ฟังชั่นผลลัพธ์
str=get(handles.input,'String');
str=evel(str);
set(handles.result,'String',str);
str=get(handles.input,'String');
str=eval(str,'.');
set(handles.result,'String',str);
 การเรียกภาพ
เปิด browse for folder เพื่อเปิดไฟล์ภาพ
เรียกไฟล์ภาพโดย imread (ชื่อไฟล์ที่อยู่ของภาพในไดเรกทอรี่) กรณีที่เปิดที่อยู่ของ
ไฟล์แล้ว พิมพ์แต่ชื่อไฟล์
ตัวเลขทั้งหมดคือสีต่างๆ
ในภาพ
บอกให้ทราบว่าเป็น
ภาพสี
figure,imshow(I) คือฟังก์ชันให้แสดงภาพ
Figure คือ พื้นที่สาหรับเรียกภาพ , กราฟ
I คือ ชื่อภาพที่ได้ถูกกาหนดขึ้น
 การเปลี่ยนภาพสีเป็นสีเทา
Ggray = rgb2gray(I)
Imhist คือฟังก์ชันบอกค่ากราฟ
กราฟที่เห็นในภาพคือจานวนพิกเซล
Im2bw การทาภาพขาวดา
 การทาตารางเมตริกซ์
**จานวนเลขต้องเท่ากัน ค่าตัวเลขต่างกันได้**
Image คือบอกค่าสี
Colorbar แสดงเฉดสี
ตารางเมตริกซ์
 การเรียกกล้อง webcam
Imaqtool เรียกกล้องเว็บแคม
เลือก Start priview
 การทาภาพ 3มิติ
เปิดภาพ กด seract แล้วกด crop ภาพทางซ้าย แล้วกด ctrl z เพื่อกลับมาทาข้างขวา
ใช้new script คือการเขียนคาสั่งทีเดียว
คาสั่งเปลี่ยนภาพสีเป็นเทา
L1 = rgb2gray(imread('left.jpg'));
L2 = rgb2gray(imread('right.jpg'));
เปลี่ยนภาพเทา เป็น แดง-ฟ้าอ่อน
ตรงไตเติล จะพิมพ์ตัวเล็กหรือตัวพิมพ์ใหญ่ก็ได้
hold on;
ให้ภาพอยู่ในเฟลมเดียวกัน
Code การเขียนภาพ 3 มิติ
I1 = rgb2gray(imread('Lion1.jpg'));
I2 = rgb2gray(imread('Lion2.jpg'));
imshowpair(I1, I2,'montage');
title('I1 (left); I2 (right)');
figure;
imshowpair(I1,I2,'ColorChannels','red-cyan');
title('Composite Image (Red - Left Image, Cyan - Right Image)');
blobs1 = detectSURFFeatures(I1, 'MetricThreshold', 2000);
blobs2 = detectSURFFeatures(I2, 'MetricThreshold', 2000);
figure;
imshow(I1);
hold on;
plot(selectStrongest(blobs1, 30));
title('Thirty strongest SURF features in I1');
figure;
imshow(I2);
hold on;
plot(selectStrongest(blobs2, 30));
title('Thirty strongest SURF features in I2');
[features1, validBlobs1] = extractFeatures(I1, blobs1);
[features2, validBlobs2] = extractFeatures(I2, blobs2);
indexPairs = matchFeatures(features1, features2, 'Metric', 'SAD', ...
'MatchThreshold', 5);
matchedPoints1 = validBlobs1(indexPairs(:,1),:);
matchedPoints2 = validBlobs2(indexPairs(:,2),:);
figure;
showMatchedFeatures(I1, I2, matchedPoints1, matchedPoints2);
legend('Putatively matched points in I1', 'Putatively matched points in I2');
[fMatrix, epipolarInliers, status] = estimateFundamentalMatrix(...
matchedPoints1, matchedPoints2, 'Method', 'RANSAC', ...
'NumTrials', 10000, 'DistanceThreshold', 0.1, 'Confidence', 99.99);
if status ~= 0 || isEpipoleInImage(fMatrix, size(I1)) ...
|| isEpipoleInImage(fMatrix', size(I2))
error(['Either not enough matching points were found or '...
'the epipoles are inside the images. You may need to '...
'inspect and improve the quality of detected features ',...
'and/or improve the quality of your images.']);
end
inlierPoints1 = matchedPoints1(epipolarInliers, :);
inlierPoints2 = matchedPoints2(epipolarInliers, :);
figure;
showMatchedFeatures(I1, I2, inlierPoints1, inlierPoints2);
legend('Inlier points in I1', 'Inlier points in I2');
[t1, t2] = estimateUncalibratedRectification(fMatrix, ...
inlierPoints1.Location, inlierPoints2.Location, size(I2));
tform1 = projective2d(t1);
tform2 = projective2d(t2);
I1Rect = imwarp(I1, tform1, 'OutputView', imref2d(size(I1)));
I2Rect = imwarp(I2, tform2, 'OutputView', imref2d(size(I2)));
% transform the points to visualize them together with the rectified images
pts1Rect = transformPointsForward(tform1, inlierPoints1.Location);
pts2Rect = transformPointsForward(tform2, inlierPoints2.Location);
figure;
showMatchedFeatures(I1Rect, I2Rect, pts1Rect, pts2Rect);
legend('Inlier points in rectified I1', 'Inlier points in rectified I2');
Irectified = cvexTransformImagePair(I1, tform1, I2, tform2);
figure;
imshow(Irectified);
title('Rectified Stereo Images (Red - Left Image, Cyan - Right Image)');
cvexRectifyImages('left.jpg', 'right.jpg');
 การเปลี่ยนสีภาพเป็น RGB (สีจากแม่สี 3 สี คือสีแดง สีเขียว และสี
น้าเงิน)
ใช้imread ในการเรียกภาพ โดยพิมพ์imread ตามด้วยชื่อภาพและ
นามสกุลของภาพ เช่น imread(‘B40.TIP’) ภาพจะปรากฏขึ้นดังรูป
ใช้คาสั่ง imshow ทาการเปลี่ยนแม่แบบสีให้เป็น RGB
ใช้code NIR = histeq(imread('B40.TIF'));
G = histeq(imread('B50.TIP'));
R = histeq(imread ('B40.TIP'));
RGB = cat(3,NIR,G.R);
figure,imshow(RGB);
เมื่อกด F5 ภาพจะเปลี่ยนเป็นเหมือนภาพด้านบน

More Related Content

What's hot (12)

3.8 การทำงานแบบลำดับ
3.8 การทำงานแบบลำดับ3.8 การทำงานแบบลำดับ
3.8 การทำงานแบบลำดับ
 
Tec4
Tec4Tec4
Tec4
 
ารเขียนอัลกอลิทึมแบบโฟล์วชาร์ต
ารเขียนอัลกอลิทึมแบบโฟล์วชาร์ตารเขียนอัลกอลิทึมแบบโฟล์วชาร์ต
ารเขียนอัลกอลิทึมแบบโฟล์วชาร์ต
 
C lang
C langC lang
C lang
 
ฟังก์ชันเอกโพแนนเชียล
ฟังก์ชันเอกโพแนนเชียลฟังก์ชันเอกโพแนนเชียล
ฟังก์ชันเอกโพแนนเชียล
 
linear function
linear functionlinear function
linear function
 
Matlab นางสาว-สุนิษา-คงงาม-58670054
Matlab นางสาว-สุนิษา-คงงาม-58670054Matlab นางสาว-สุนิษา-คงงาม-58670054
Matlab นางสาว-สุนิษา-คงงาม-58670054
 
Matlab นางสาว-ณัฐกานต์-การปลูก-58670013-3305
Matlab นางสาว-ณัฐกานต์-การปลูก-58670013-3305Matlab นางสาว-ณัฐกานต์-การปลูก-58670013-3305
Matlab นางสาว-ณัฐกานต์-การปลูก-58670013-3305
 
เลขฐานสิบหก (Hexadecimal)
เลขฐานสิบหก (Hexadecimal)เลขฐานสิบหก (Hexadecimal)
เลขฐานสิบหก (Hexadecimal)
 
Expolog clipvidva
Expolog clipvidvaExpolog clipvidva
Expolog clipvidva
 
Chapter 02 Flowchart
Chapter 02 FlowchartChapter 02 Flowchart
Chapter 02 Flowchart
 
207
207207
207
 

Similar to โปรแกรม Matlap

ปิยวรรณ
ปิยวรรณปิยวรรณ
ปิยวรรณFirstii Romeo
 
น.ส.ลลิตภัทร สงวนผิว 58670381 กลุ่ม3302
น.ส.ลลิตภัทร สงวนผิว 58670381 กลุ่ม3302น.ส.ลลิตภัทร สงวนผิว 58670381 กลุ่ม3302
น.ส.ลลิตภัทร สงวนผิว 58670381 กลุ่ม3302Nawarat Sornchai
 
09 multi arrays
09 multi arrays09 multi arrays
09 multi arraysa-num Sara
 
Computer programming
Computer programmingComputer programming
Computer programmingJariyaa
 

Similar to โปรแกรม Matlap (6)

58170110 01
58170110 0158170110 01
58170110 01
 
ปิยวรรณ
ปิยวรรณปิยวรรณ
ปิยวรรณ
 
น.ส.ลลิตภัทร สงวนผิว 58670381 กลุ่ม3302
น.ส.ลลิตภัทร สงวนผิว 58670381 กลุ่ม3302น.ส.ลลิตภัทร สงวนผิว 58670381 กลุ่ม3302
น.ส.ลลิตภัทร สงวนผิว 58670381 กลุ่ม3302
 
09 multi arrays
09 multi arrays09 multi arrays
09 multi arrays
 
Computer programming
Computer programmingComputer programming
Computer programming
 
Matlap
MatlapMatlap
Matlap
 

โปรแกรม Matlap