开发者

Is it possible for tick marks on an image to be centered around the -edge- of a pixel?

If I make a 4 pixel by 4 pixel image in Matlab using the image() command, it centers the tick marks in the middle of the pixels. I want the tick marks to be centered on t开发者_如何转开发he lower left corner of the pixel. Is there some way to do this?


You can specify x and y coordinates of the pixels and shift them by 0.5:

image([0.5,3.5],[0.5,3.5],magic(4))


I think this code will do what you want. It places tick marks only at the edges of the pixels:

A = ...;  %# Your 4-by-4 matrix
image([0.5 3.5],[0.5 3.5],A);      %# Pixel edges are at 0, 1, 2, 3, and 4
set(gca,'XTick',0:4,'YTick',0:4);  %# Place tick marks at 0, 1, 2, 3, and 4


Try the following:

a = randi([0 255], [4 4]);
figure, imagesc(a), caxis([0 255])

b = zeros( size(a)+1 );
b(1:end-1,1:end-1) = a;
figure, pcolor(b), caxis([0 255]), axis ij

Note that I extended the matrix a because pcolor drops the last row/column.

Is it possible for tick marks on an image to be centered around the -edge- of a pixel?

Is it possible for tick marks on an image to be centered around the -edge- of a pixel?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜