Home > Archive > Matlab > November 2005 > show image in x-z plane
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
show image in x-z plane
|
|
| Kathy Coughlin 2005-11-22, 7:05 pm |
| Is it possible to show an image in a plane other than the x-y plane?
I have a stereo pair of images (ImageA and ImageB). I also have a
set of vertices and faces that represent a 3D CAD model of the object
in the images. I would like to show the x-z and y-z view of the
object, with the appropriate image in the background. Here is a
simplified version of my code:
% ========================================
============
imageA = imread('a.jpg');
imageB = imread('b.jpg');
% --- cube faces and vertices
f = [1 2 6 5;...
2 3 7 6;...
3 4 8 7;...
4 1 5 8;...
1 2 3 4;...
5 6 7 8];
v = [ 0 0 0; ...
1 0 0;...
1 1 0;...
0 1 0;...
0 0 1;...
1 0 1;...
1 1 1; ...
0 1 1];
% --- place cube in center of image
[m,n] = size(imageA);
MIN = min([m,n]);
scale = 0.25*MIN;
offsetX = 0.5*n;
offsetY = 0.5*m;
vv = scale*v;
V(:,1) = vv(:,1) + offsetX*ones(size(vv(:,1)));
V(:,2) = vv(:,2) + offsetY*ones(size(vv(:,2)));
V(:,3) = vv(:,3);
% --- show cube and corresponding image in x-z and y-z views
figure;
subplot(1,2,1), imshow(imageA);
subplot(1,2,1), hold on;
subplot(1,2,1), xlabel('x'); ylabel('y'); zlabel('z');
subplot(1,2,1),
patch('Vertices',V,'Faces',f,'FaceVertex
CData',hsv(6),'FaceColor','fla
t')
subplot(1,2,1), view(0,0);
subplot(1,2,1), title('x-z view');
subplot(1,2,2), imshow(imageB);
subplot(1,2,2), hold on;
subplot(1,2,2), xlabel('x'); ylabel('y'); zlabel('z');
subplot(1,2,2),
patch('Vertices',V,'Faces',f,'FaceVertex
CData',hsv(6),'FaceColor','fla
t')
subplot(1,2,2), view(90,0);
subplot(1,2,2), title('y-z view');
% ========================================
============
Can someone show me how to show the image in the x-z or y-z plane?
Thank you,
Kathy
| |
|
| Kathy Coughlin wrote:
>
>
> Is it possible to show an image in a plane other than the x-y
> plane?
>
> I have a stereo pair of images (ImageA and ImageB). I also have a
> set of vertices and faces that represent a 3D CAD model of the
> object
> in the images. I would like to show the x-z and y-z view of the
> object, with the appropriate image in the background. Here is a
> simplified version of my code:
>
> % ========================================
============
> imageA = imread('a.jpg');
> imageB = imread('b.jpg');
>
> % --- cube faces and vertices
> f = [1 2 6 5;...
> 2 3 7 6;...
> 3 4 8 7;...
> 4 1 5 8;...
> 1 2 3 4;...
> 5 6 7 8];
>
> v = [ 0 0 0; ...
> 1 0 0;...
> 1 1 0;...
> 0 1 0;...
> 0 0 1;...
> 1 0 1;...
> 1 1 1; ...
> 0 1 1];
>
> % --- place cube in center of image
>
> [m,n] = size(imageA);
> MIN = min([m,n]);
> scale = 0.25*MIN;
> offsetX = 0.5*n;
> offsetY = 0.5*m;
>
> vv = scale*v;
>
> V(:,1) = vv(:,1) + offsetX*ones(size(vv(:,1)));
> V(:,2) = vv(:,2) + offsetY*ones(size(vv(:,2)));
> V(:,3) = vv(:,3);
>
> % --- show cube and corresponding image in x-z and y-z views
>
> figure;
>
> subplot(1,2,1), imshow(imageA);
> subplot(1,2,1), hold on;
> subplot(1,2,1), xlabel('x'); ylabel('y'); zlabel('z');
> subplot(1,2,1),
>
patch('Vertices',V,'Faces',f,'FaceVertex
CData',hsv(6),'FaceColor','f
> la
> t')
> subplot(1,2,1), view(0,0);
> subplot(1,2,1), title('x-z view');
>
> subplot(1,2,2), imshow(imageB);
> subplot(1,2,2), hold on;
> subplot(1,2,2), xlabel('x'); ylabel('y'); zlabel('z');
> subplot(1,2,2),
>
patch('Vertices',V,'Faces',f,'FaceVertex
CData',hsv(6),'FaceColor','f
> la
> t')
> subplot(1,2,2), view(90,0);
> subplot(1,2,2), title('y-z view');
>
> % ========================================
============
>
> Can someone show me how to show the image in the x-z or y-z plane?
>
> Thank you,
>
> Kathy
Interesting question. Bumping this to the top.
Scott
| |
| krasmuzik@techemail.com 2005-11-24, 4:02 am |
| How about adding the image onto the last xz 2D matrix of the larger 3D
matrix. The first xz matrixes are your 3D data shown with whatever 3D
graphing commands - then do a hold on and show the last matrix using
the slice command. I do this to add alpha blended 'walls' around my
3D matrix showing the edge conditions while I look at the isocontours
in the data.
SLICE(X,Y,Z,V,XI,YI,ZI) draws slices through the volume V along the
surface defined by the arrays XI,YI,ZI.
see "Slicing Fluid Flow Data Example" in help for something similar -
just add the image data as the edge slices.
|
|
|
|
|