在matlab中,如何在图像上绘制网格 [英] In matlab, how to draw a grid over an image

查看:1510
本文介绍了在matlab中,如何在图像上绘制网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在图像上绘制网格。它应该成为该图像本身的一部分。
它应该能够在图像本身上显示一些行和列。可以指定行和列的行。
实际上,我对一些研究论文讨论他们关于图像变形的结果的方式感到鼓舞。其中一个链接是:中链接到Steve Eddins的博客如何绘制图像并向其添加线条的示例。但是,如果要在显示的图像上保存或执行处理,则必须将显示的图像保存为图像矩阵。如何执行此操作已在以下其他SO问题中进行了讨论:




How to draw a grid over an image. It should become part of that image itself. It should be able to show some rows and columns over the image itself. The lines for rows and columns can be specified. Actually I was encouraged by the way some research paper discusses about the results they have about image warping. One of the links is this: http://www.hammerhead.com/thad/morph.html

解决方案

There are a number of related questions on SO that discuss ways to modify an image. Here are the two general approaches:

1. Modify the image data directly: I discuss this in my answer to this other SO question. Since image data can be 2-D or 3-D, you can use multidimensional indexing to modify the raw image data, creating lines along given rows and columns. Here's an example that changes every 10 rows and columns in the image to black:

img = imread('peppers.png');  %# Load a sample 3-D RGB image
img(10:10:end,:,:) = 0;       %# Change every tenth row to black
img(:,10:10:end,:) = 0;       %# Change every tenth column to black
imshow(img);                  %# Display the image

And now the image data in the variable img has black lines on it, and you can write it to a file or do whatever other processing you want to it.

2. Plot the image and the lines, then turn the axes/figure into a new image: The link to Steve Eddins' blog in zellus' answer shows an example of how you can plot an image and add lines to it. However, if you want to save or perform processing on the displayed image, you will have to save the displayed image as an image matrix. How you can do this has been discussed in these other SO questions:

这篇关于在matlab中,如何在图像上绘制网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆