More Related Content Similar to Matlab 58170042 (1) Similar to Matlab 58170042 (1) (6) More from Beer Srisudaporn More from Beer Srisudaporn (14) Matlab 58170042 (1)2. แมตแล็บ (อังกฤษ: MATLAB: Matrix Laboratory) เป็นซอฟต์แวร์ในการคานวณและการเขียน
โปรแกรม โปรแกรมหนึ่ง ที่มีความสามารถครอบคลุมตั้งแต่ การพัฒนาอัลกอริธึม การสร้างแบบจาลองทาง
คณิตศาสตร์ และการทาซิมูเลชั่นของระบบ การสร้างระบบควบคุม และโดยเฉพาะเรื่อง image processing
และ wavelet การสร้างเมตริกซ์ ผลิตโดยบริษัทแมตเวิรกส์ ตัวแทนจาหน่ายในประเทศไทยคือ บริษัท เทค
ซอร์ส ซิสเท็มส์ (ประเทศไทย) จากัด
แมตแล็บเป็นโปรแกรมสาเร็จรูปที่ใช้กันอย่างแพร่หลายในแวดวงของนักวิทยาศาสตร์และ วิศวกร
ในปัจจุบัน ชื่อโปรแกรม MATLAB นั้นย่อมาจาก Matrix Laboratory แมตแล็บได้เริ่มต้น ขึ้นเพื่อต้องการให้
เราสามารถแก้ปัญหาตัวแปรที่มีลักษณะเป็นเมทริดซ์ได้ง่ายขึ้น แมตแล็บ เริ่มพัฒนาครั้งแรกโดย Dr. Cleve
Molor ซึ่งเขียนโปรแกรมนี้ขึ้นมาด้วยภาษาฟอร์แทรน โดยโปรแกรมนี้ได้พัฒนาภายใต้โครงการ LINPACK
และ EISPACK
การทางานของโปรแกรม
แมตแล็บสามารถทางานได้ทั้งในลักษณะของการติดต่อโดยตรง คือการเขียนคาสั่งเข้าไปทีละคาสั่ง
เพื่อให้แมตแล็บประมวลผลไปเรื่อยๆ หรือสามารถที่จะรวบรวม ชุดคาสั่งเรานั้นเป็นโปรแกรมก็ได้ข้อ
สาคัญอย่างหนึ่งของแมตแล็บก็คือข้อมูลทุกตัวจะถูกเก็บใน ลักษณะของแถวลาดับ คือในแต่ละตัวแปรจะ
ได้รับการแบ่งเป็นส่วนย่อยเล็กๆขึ้น ซึ่งการใช้ตัวแปรเป็นแถวลาดับ ในแมตแล็บเราไม่จาเป็นที่จะต้องจอง
มิติเหมือนกับ การเขียนโปรแกรมในภาษาขั้นต่าทั่วไป ซึ่งทาให้เราสามารถที่จะแก้ปัญหาของตัวแปรที่อยู่ใน
ลักษณะ ของเมทริกซ์และเวกเตอร์ได้โดยง่าย ซึ่งทาให้เราลดเวลาการทางานลงได้อย่างมากเมื่อเทียบกับการ
เขียน โปรแกรมโดยภาษาซีหรือภาษาฟอร์แทรน
4. >> plot(a)
>> x = [-3:1:3];
>> y = [-3:1:3];
>> [xx,yy] = meshgrid(x,y);
>> zz = xx.^2 - yy.^2;
>> figure
>> surf(xx,yy,zz)
>> shading interp
>> colorbar
7. การทา 3D stereo
1ตัดรูป 3d stereo แบ่งออก ซ้าย-ขวา
Browse เอานารูปที่ตัดแล้วเข้ามา
ใส่โค้ดใน command line
I1 = rgb2gray(imread('pic1.jpg'));
I2 = rgb2gray(imread('pic2.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;
8. 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('lions_left.jpg', 'lion_right.jpg');
กด Run จะแสดงผลเป็นภาพ 3D
15. หลังจาก save จะได้โค้ดแบบนี้
แล้ว copy โค้ดข้างล่างนี้
global x
[filename, pathname] = uigetfile('*.jpg','Load Image');
if filename==0
msgbox('Please Choose Image','Error')
return
end
x=imread(filename);
axes(handles.axes1);
imshow(x); title('Loaded Image');
ไปวางในบรรทัดที่ 81
16. แล้ว copy โค้ดนี้ไปใส่ในบรรทัดที่ 57
set(handles.axes1,'Visible','off');
จากนั้นคลิกที่ปุ่ม gray ทาเหมือนข้างบน copy โค้ดด้านล่างไปใส่ในบรรทัดที่ 97
global x
a=rgb2gray(x)
18. จากนั้นคลิกที่ปุ่ม BW ทาเหมือนข้างบน copy โค้ดด้านล่างไปใส่ในบรรทัดที่ 117
global x
c=rgb2gray(x)
imhist(c);
axes(handles.axes1);
จากนั้นคลิกที่ปุ่ม reset ทาเหมือนข้างบน copy โค้ดด้านล่างไปใส่ในบรรทัดที่ 117
global x
axes(handles.axes1);
imshow(x);
22. การผสมสีภาพ browse folder
Select Folder
กด new script และวางโค้ด
R = histeq(imread('D:Com_proLS5B40.TIF'));
G = histeq(imread('D:Com_proLS5B50.TIF'));
B = histeq(imread('D:Com_proLS5B30.TIF'));