ศราวุธ 58670394

35
โปรแกรม MATLAB clc เคลียทั้งหมด โลเวกเตอร์

Upload: nontawatzj

Post on 11-Apr-2017

71 views

Category:

Art & Photos


0 download

TRANSCRIPT

Page 1: ศราวุธ 58670394

โปรแกรม MATLAB

clc เคลียทั้งหมด โลเวกเตอร์

Page 2: ศราวุธ 58670394

เมททิก >> A = [123;456;789] A = 123 456 789 >> A =[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 >> A(3,2) ans = 8

>> B = [1:20] B = Columns 1 through 17

Page 3: ศราวุธ 58670394

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Columns 18 through 20 18 19 20 >> B = [1:2:20]

B = 1 3 5 7 9 11 13 15 17 19 >> B = [0:2:20] B = 0 2 4 6 8 10 12 14 16 18 20 >> whos Name Size Bytes Class Attributes A 3x3 72 double B 1x11 88 double ans 1x1 8 double sun 1x1 8 double x 5x1 40 double y 1x5 40 double

Page 4: ศราวุธ 58670394

>> x = sin(2) x = 0.9093 >> x = cos(2) x = -0.4161

Page 5: ศราวุธ 58670394

คร้ัง2 เวกเตอร์ กราฟ >> x = [5 7 28]; >> y = [1 2 3]; >> plot(x,y)

Page 6: ศราวุธ 58670394

>> x = [5 7 28]; >> y = [1 2 3]; >> plot(x,y) >> title('Your score')

>> xlabel('people') >> ylabel('score')

Page 7: ศราวุธ 58670394

>> plot(x,y,'red') เปลี่ยนสีกราฟ

>> plot(x,y,'--r') เปลี่ยนเส้นกราฟจากเส้นตรงเป็นเส้นประ

Page 8: ศราวุธ 58670394

>> plot(x,y,'-+r') เพิ่มจุดบอกเข้าไปในเส้นกราฟ

>> plot(x,y,'-ro') เพิ่มจุดวงกลมเข้าไปในเส้นกราฟ

Page 9: ศราวุธ 58670394

>> plot(x,y,'-.k') ท าให้เส้นกราฟเป็นเส้นประและจุด

ข้อมูลเส้นกราฟแต่ละเส้น

>> x = [2 5 7 8];

>> y = [3 5 9 8];

>> z = [2 6 9 4];

>> t = [1 2 3 4];

>> plot(x,t,'--r',y,t,'-.k',z,t,'-og')

Page 10: ศราวุธ 58670394

แสดงข้อมูลกราฟ >> legend('people','money','salary')

ย้ายข้อมูลกราฟ

legend('location','northwest')

Page 11: ศราวุธ 58670394

>> figure

>> subplot(2,2,1)

Page 12: ศราวุธ 58670394

>> subplot(2,2,1)

>> plot(x,t) >> subplot(2,2,2) >> plot(y,t) >> subplot(2,2,3) >> plot(z,t)

Page 13: ศราวุธ 58670394

กราฟสามมิติ

[x,y] = meshgrid([-2:.2:2]);

Z = x.*exp(-x.^2-y.^2); figure surf(x,y,Z,gradient(Z)) gradient(Z) colorbar

Page 14: ศราวุธ 58670394

ภาพทางภูมิศาสตร์

topotoolbox-master

DEM

Page 15: ศราวุธ 58670394

> DEM = GRIDobj('kidchakood.tif')

>> imagesc(DEM)

Page 16: ศราวุธ 58670394

ปรับภาพให้เห็นชันเจนมากขึ้น

>> imageschs(DEM,min(gradient8(DEM),1))

ท าภาพทางภูมิสาศตร์ให้เป็นสามมิติ

>> DEMc = crop(DEM,sub2ind(DEM.size,[150 350],[150 350])); >> [Z,x,y] = GRIDobj2mat(DEMc); >> surf(x,y,double(Z))

Page 17: ศราวุธ 58670394

GRIDobjascii(DEMc,'test.txt'); GRIDobj2geotiff(DEMc,'test.tif');

DEMf = fillsinks(DEM); >> FD = FLOWobj(DEMf); >> A = flowacc(FD); >> imageschs(DEM,dilate(sqrt(A),ones(5)),'colormap',flipud(copper));

Page 18: ศราวุธ 58670394

การปรับเปลี่ยนโทนสีของภาพ

a = imread(‘2.jpg’)

Page 19: ศราวุธ 58670394

>> whos a

>> figure,imshow(a)

Page 20: ศราวุธ 58670394

ปรับภาพให้เป็นสีเทา

i = rgb2gray(a)

figure,imshow(i)

Page 21: ศราวุธ 58670394

b = imread('3.jpg')

>> p = imadjust(b)ปรับแก้ภาพให้คมชัด

Page 22: ศราวุธ 58670394

>> figure,imshow(b)

>> figure,imshow(p)

Page 23: ศราวุธ 58670394

>> imhist(b)กรองข้อมลภาพ

>> imhist(p)กรองข้อมลภาพ

Page 24: ศราวุธ 58670394

>> bw = im2bw(a)ภาพขาวด า figure,imshow(bw)

Page 25: ศราวุธ 58670394

การท าภาพให้เป็นสามมิติ เรียกภาพที่เราเลือก vid = videoinput('winvideo', 1, 'MJPG_1280x720'); preview(vid) for i=1:10 img=getsnapshot(vid); fname=['Image',num2str(i)]; imwrite(img,fname,'jpg'); pause(2); end 3D

Page 26: ศราวุธ 58670394

ปรับให้เป็นสามมิติ I1 = rgb2gray(imread('left.jpg')); I2 = rgb2gray(imread('right.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');

Page 27: ศราวุธ 58670394

[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('left1.jpg', 'right1.jpg');

Page 28: ศราวุธ 58670394
Page 29: ศราวุธ 58670394

สร้างโปรแกรมปรับภาพ guide เรียกค าสั่งโปนแกรม

ปรับแต่งโปรแกมเพิ่มค าสั่ง

Page 30: ศราวุธ 58670394
Page 31: ศราวุธ 58670394

สร้างปุมกดแต่ละค าสั่ง

Page 32: ศราวุธ 58670394

สร้างพื้นที่ส าหรับภาพ

เปลี่ยนสี ชือมุม

Page 33: ศราวุธ 58670394
Page 34: ศราวุธ 58670394

เรียกภาพที่ภูมิศาสตร์

Page 35: ศราวุธ 58670394

เปลี่ยนสีภาพทางภูมิศาสตร์