How to change Y-axis coordinates of meshgrid

19 visualizaciones (últimos 30 días)
Med Future
Med Future el 20 de Mzo. de 2022
Respondida: Image Analyst el 22 de Mzo. de 2022
Hello Everyone, i hope you are doing well. I am creating binary Image in which background is black and forground is white
when i create grid of 1000x1000. The X-axis start from 0 to 1000 but Y axis is upper side 0 to 1000 as you can see in the following image , but i want Y axis to be start from Lower 0 to 1000
How can i do that in MATLAB
imSz = 1000; % assuming images are 1000x1000
imbg = false(imSz); % background "color"
imfg = ~imbg(1,1);
[~,Y] = meshgrid(1:imSz); % make a grid
% black and white image
BW = imbg;
imshow(BW)
axis on;

Respuesta aceptada

Image Analyst
Image Analyst el 22 de Mzo. de 2022
That's the convention for matrixes and images - the y=1 value is at the top. If you want to reverse it use "axis xy" like
grayImage = imread('cameraman.tif');
[rows, columns, numberOfColorChannels] = size(grayImage);
subplot(2, 1, 1);
imshow(grayImage);
axis('on', 'xy');
subplot(2, 1, 2);
imshow(flipud(grayImage));
axis('on', 'xy');

Más respuestas (2)

KSSV
KSSV el 20 de Mzo. de 2022
>> hax = gca;
hax.YTickLabel = flipud(hax.YTickLabel);
  3 comentarios
KSSV
KSSV el 20 de Mzo. de 2022
[~,Y] = meshgrid(imSz:-1:1); % make a grid
Med Future
Med Future el 20 de Mzo. de 2022
@KSSV Still not working. same result as above

Iniciar sesión para comentar.


yanqi liu
yanqi liu el 21 de Mzo. de 2022
imSz = 1000; % assuming images are 1000x1000
imbg = false(imSz); % background "color"
imfg = ~imbg(1,1);
[~,Y] = meshgrid(1:imSz); % make a grid
% black and white image
BW = imbg;
imshow(BW)
axis on;
axis xy
  2 comentarios
Med Future
Med Future el 21 de Mzo. de 2022
@yanqi liu What changes you have made?
yanqi liu
yanqi liu el 22 de Mzo. de 2022
yes,sir,use axis xy to make the coordinate as norma xy axis, not use image axis

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by