Plot a 2D image in projected coordinate systems.

조회 수: 22 (최근 30일)
Haraldur Blöndal Kristjánsson
Haraldur Blöndal Kristjánsson 2020년 9월 25일
편집: Matt J 2020년 9월 25일
I am not sure if the title describes my problem well enough - trying to get used to the notation and things like that in linear algebra and geography.
To start with then I have this image and it is represented in a 2D matrix, call it A. I want to project it onto a plane normal to n=[1,2,3]. I believe I have understood how to find the perpendular vectors from A to the normal plane.
(hope I am using the right words but meaning the vector going from the origin, parallell to the normal vector creates a 90 degree corner with the vector going from the normal plain to another vector in the original image 2D - creating right triangle)
Anyhow I will describe it a bit, so if you have the mathimatical understanding to tell me wrong it would be nice, because then I do not need the Matlab help yet. My matrix A started with [1; -90] so I used that as the origin (x0,y0,z0) (z would be 0 right in 2D?) then I took just the next vector from the A [1; -91] as (x1,y1,z1) n = (a,b,c) then I need to find t so that (x0,y0,z0) (x1,x2,x3) and (x0+ta,y0+tb,z0+tc) make right triangle and then the point (x0+ta,y0+tb,z0+tc) is the projection of [1;-91].
t = ((a*x1-ax0)+(b*x1-b*x0) + (c*x1-c*x0))/(a² + b² + c²)
t = 0.142857 and the I could find the projected image by A (original image) + t*n(the normal vector).
Ok, hope someone understood my... my Matlab question is how can I plot visually this new 3*10095 matrix so I have the three axis in the plot (seeing the image laying down on the z axis after the transformation)?

답변 (1개)

Matt J
Matt J 2020년 9월 25일
편집: Matt J 2020년 9월 25일
I do not understand how a 3*10095 matrix is being interpreted as an image. You don't to have any pixel values, as far as I can see. If you just want to plot a cloud of 3D points, you would use scatter3().
  댓글 수: 4
Haraldur Blöndal Kristjánsson
Haraldur Blöndal Kristjánsson 2020년 9월 25일
Yes, thanks a lot. It worked for me, I had bit of a problem to figure out how to extract the rows - but got it now:
scatter3(A(1,:,:),A(2,:,:),A(3,:,:),1,[0 0 0])¸
Is it possible to combine the previous matrix and the projected one in same plot ?
Like previous is:
scatter3(R(1,:,:),R(2,:,:),R(3,:,:),1,[0 0 0])
Latter:
scatter3(A(1,:,:),A(2,:,:),A(3,:,:),1,[0 0 0])
And when I run the script I could see them intersecting
Matt J
Matt J 2020년 9월 25일
편집: Matt J 2020년 9월 25일
Yes, you can use hold():
hold on
scatter3(R(1,:,:),R(2,:,:),R(3,:,:),1,[0 0 0])
scatter3(A(1,:,:),A(2,:,:),A(3,:,:),1,[0 0 0])
hold off

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by