How to implement a nonlinear grid into an image?
조회 수: 13 (최근 30일)
이전 댓글 표시
Dear all,
I have an image from a matrix that I want to plot with pcolor.
My problem is that each pixel in my image should not have the same size, my grid should be non-linear.
But it is not the usual non linearity that you can define in x then in y and finally plot your image as pcolor(x, y, M).
I place in copy my matrix, named M, and the grid it should fit into, named G (if you plot imagesc(G) you can see the non-linearity with cylindrical symmetry I’d like to have in M).
Would someone know how to do that?
If you need more info, please let me know.
Thanks in advance.
댓글 수: 0
답변 (1개)
Mike Garrity
2016년 1월 21일
The image object won't do that. It does linear interpolation between the coordinates of its corners. You need to use a graphics object that has coordinates for each pixel.
The one issue with pcolor is that it only supports colormapped images. If you've got a true color image, it won't work. But you can do the same thing that pcolor does. What it's doing is creating a surface with the ZData set to 0's. So you can replicate that with a truecolor image like so:
img = imread('street1.jpg');
w = size(img,2);
h = size(img,1);
x = sin(linspace(-pi/2,pi/2,w)).^3;
y = (w/h)*sin(linspace(-pi/2,pi/2,h)).^3;
h = surf(x,y,zeros(h,w),img,'EdgeColor','none');
view(2)
axis ij
Just replace the X & Y with your grid.
참고 항목
카테고리
Help Center 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!