Is it possible for the marks in the image to be centered around the pixel element?

If I take a 4-pixel by 4-pixel image in Matlab using the image () command, it centers the mark marks in the middle of the pixels. I want the labels to be centered in the lower left corner of the pixel. Is there any way to do this?

+3
source share
3 answers

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

image([0.5,3.5],[0.5,3.5],magic(4))
+1
source

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

Please note that I expanded the matrix abecause it pcolordeletes the last row / column.

AB

+1
source

, , . :

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
+1

Source: https://habr.com/ru/post/1741530/


All Articles