ศราวุธ 58670394
TRANSCRIPT
โปรแกรม MATLAB
clc เคลียทั้งหมด โลเวกเตอร์
เมททิก >> 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
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
>> x = sin(2) x = 0.9093 >> x = cos(2) x = -0.4161
คร้ัง2 เวกเตอร์ กราฟ >> x = [5 7 28]; >> y = [1 2 3]; >> plot(x,y)
>> x = [5 7 28]; >> y = [1 2 3]; >> plot(x,y) >> title('Your score')
>> xlabel('people') >> ylabel('score')
>> plot(x,y,'red') เปลี่ยนสีกราฟ
>> plot(x,y,'--r') เปลี่ยนเส้นกราฟจากเส้นตรงเป็นเส้นประ
>> plot(x,y,'-+r') เพิ่มจุดบอกเข้าไปในเส้นกราฟ
>> plot(x,y,'-ro') เพิ่มจุดวงกลมเข้าไปในเส้นกราฟ
>> 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')
แสดงข้อมูลกราฟ >> legend('people','money','salary')
ย้ายข้อมูลกราฟ
legend('location','northwest')
>> figure
>> subplot(2,2,1)
>> subplot(2,2,1)
>> plot(x,t) >> subplot(2,2,2) >> plot(y,t) >> subplot(2,2,3) >> plot(z,t)
กราฟสามมิติ
[x,y] = meshgrid([-2:.2:2]);
Z = x.*exp(-x.^2-y.^2); figure surf(x,y,Z,gradient(Z)) gradient(Z) colorbar
ภาพทางภูมิศาสตร์
topotoolbox-master
DEM
> DEM = GRIDobj('kidchakood.tif')
>> imagesc(DEM)
ปรับภาพให้เห็นชันเจนมากขึ้น
>> 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))
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));
การปรับเปลี่ยนโทนสีของภาพ
a = imread(‘2.jpg’)
>> whos a
>> figure,imshow(a)
ปรับภาพให้เป็นสีเทา
i = rgb2gray(a)
figure,imshow(i)
b = imread('3.jpg')
>> p = imadjust(b)ปรับแก้ภาพให้คมชัด
>> figure,imshow(b)
>> figure,imshow(p)
>> imhist(b)กรองข้อมลภาพ
>> imhist(p)กรองข้อมลภาพ
>> bw = im2bw(a)ภาพขาวด า figure,imshow(bw)
การท าภาพให้เป็นสามมิติ เรียกภาพที่เราเลือก 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
ปรับให้เป็นสามมิติ 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');
[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');
สร้างโปรแกรมปรับภาพ guide เรียกค าสั่งโปนแกรม
ปรับแต่งโปรแกมเพิ่มค าสั่ง
สร้างปุมกดแต่ละค าสั่ง
สร้างพื้นที่ส าหรับภาพ
เปลี่ยนสี ชือมุม
เรียกภาพที่ภูมิศาสตร์
เปลี่ยนสีภาพทางภูมิศาสตร์