![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/300788/image.png)
edgecolor of pixels of imagesc
조회 수: 29 (최근 30일)
이전 댓글 표시
I want the black edge color for the boundaries of each pixel drawn using imagesc. If I use pcolor, I get the black boundary around pixels. How can I get the same using 'imagesc'?
댓글 수: 0
답변 (3개)
Image Analyst
2020년 5월 25일
편집: Image Analyst
2020년 5월 25일
You can't. And if you use pcolor, you don't either. The tiles you see in pcolor are NOT pixels. Look closely. If you want to show a 4x4 array with pcolor, do you see a 4x4 array of pixels?
m = magic(4)
pcolor(m);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/300788/image.png)
No, you don't. Those black lines goes through the MIDDLE of the pixels, they don't surround them. And to make it worse, you see a 3x3 array of tiles, not a 4x4 array. Very deceiving so that's why I never use pcolor().
댓글 수: 0
Aaron T. Becker's Robot Swarm Lab
2021년 1월 25일
Consider using the code Pixel Grid, https://www.mathworks.com/matlabcentral/fileexchange/71622-pixel-grid
The function pixelgrid superimposes a grid of pixel edges on an image. The purpose is to easily visualize pixel extents when zooming in closely on an image. The grid is drawing using lines with contrasting colors so that it is visible regardless of the colors of the underlying pixels.
Cite As
Steve Eddins (2021). Pixel Grid (https://github.com/mathworks/pixelgrid), GitHub. Retrieved January 25, 2021.
댓글 수: 0
Rongxing Hu
2022년 5월 24일
You could use plot to add the edge lines
edge_x = repmat( [0:length(xdata)]+0.5, length(ydata)+1,1)
edge_y = transpose( repmat( [0:length(ydata)]+0.5, length(xdata)+1,1) )
plot(edge_x ,edge_y, ' k') % vertical lines
hold on
plot( transpose(deg_x), transpose(edge_y ), 'k') % horizontal lines
댓글 수: 1
DGM
2022년 5월 25일
You can use the editor tools to run the example code in-situ to create a more complete demonstration of the code.
m = magic(4)
imagesc(m); hold on
nx = size(m,2);
ny = size(m,1);
edge_x = repmat((0:nx)+0.5, ny+1,1);
edge_y = repmat((0:ny)+0.5, nx+1,1).';
plot(edge_x ,edge_y, ' k') % vertical lines
plot(edge_x.', edge_y.', 'k') % horizontal lines
참고 항목
카테고리
Help Center 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!