How to set up the axes of a binary Image?
5 次查看(过去 30 天)
显示 更早的评论
Hi everyone!
I would like to know if there is a method to set up the axes of a logical matrix which is a binary image. In the main code, the matrix (that is the binary image to which I refer) is called 'out' and it has dimension 241 x 321 . I would like 'out' to have in the final plot that the x- axis ranging from -1600 to 1600 and the y-axis ranging from -1200 to 1200. Can anyone help me?
采纳的回答
Image Analyst
2022-5-27
img = imread('cameraman.tif');
binaryImage = img > 150;
imshow(binaryImage, 'XData', [-1600, 1600], 'YData', [-1200, 1200]);
% Default tick marks are spaced kind of far apart. Make the closer.
xticks(-1600:200:1600)
yticks(-1200:200:1200)
axis on
0 个评论
更多回答(1 个)
Jan
2022-5-27
编辑:Jan
2022-5-27
out = rand(241, 321) > 0.6; % Binary image
axes('NextPlot', 'add', 'XLim', [-1600, 1600], 'YLim', [-1200, 1200]);
x = linspace(-1600, 1600, 321);
y = linspace(-1200, 1200, 241);
imagesc(y, x, out)
2 个评论
Jan
2022-5-27
@Loren99: Sorry, when I'm not at home on my personal computer, I do not have access to Matlab and cannot work with the provided data. Now I can open the MAT file and find this:
Icomplement: [241×321 logical]
M: [241×321 logical]
O: [3×77361 double]
Q: [3×77361 single]
ScenaDir: 'C:\Users\cotug\OneDrive\Desktop\Prova_test/Scenari/'
X: [241×321 double]
Y: [241×321 double]
Z: [241×321 double]
a: [60425×3 triangulation]
bary: [2×77361 single]
d: [77361×1 single]
dir: [3×77361 double]
dir0: [3×1 double]
faces: [60425×3 double]
filename: 'test.mat'
funcDir: 'C:\Users\cotug\OneDrive\Desktop\Prova_test/Subfunctions/'
hit: [1×77361 logical]
mainDir: 'C:\Users\cotug\OneDrive\Desktop\Prova_test/'
new_x: [1×77361 double]
new_y: [1×77361 double]
new_z: [1×77361 double]
orig: [3×77361 double]
out: [241×321 logical]
sz: [3 77361]
tree: [6×1 uint32]
trix: [77361×1 int32]
vertices: [40639×3 double]
x: [1×321 double]
y: [1×241 double]
z: 80
What do you expect the readers to do with this pile of data?
What is wrong with my random test data image, which is a 241 x 321 binary image exactlyas you explain it in the question? My code does what you are asking for: "I would like 'out' to have in the final plot that the x- axis ranging from -1600 to 1600 and the y-axis ranging from -1200 to 1200." If you now provide an image with another contents (more white pixels are the border), this does not make any difference for the code.
What is the difference between the results of my suggestion and your needs? Of course you can insert your data from the out matrix instead of my random test data.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!