I have a project on Fingerprint Matching and I got stuck at marking the points of termination and bifurcation on the image. I have already stored pixels' coordinates. How would I go about doing this?
相关问题
- How to get the background from multiple images by
- Extract matrix elements using a vector of column i
- Try to load image with Highgui.imread (OpenCV + An
- CV2 Image Error: error: (-215:Assertion failed) !s
- How do I apply a perspective transform with more t
相关文章
- How do I append metadata to an image in Matlab?
- How can I write-protect the Matlab language?
- `std::sin` is wrong in the last bit
- Python open jp2 medical images - Scipy, glymur
- Escape sequence to display apostrophe in MATLAB
- On a 64 bit machine, can I safely operate on indiv
- Converting PIL Image to GTK Pixbuf
- Vertical line fit using polyfit
Assuming that your image is stored in a grayscale image called
im
, and your points of termination and bifurcation are stored in 2D matrices where the first column denotes the row and the second column denotes the column of each point, you can easily do this usingsub2ind
.sub2ind
converts 2D co-ordinates into linear indices so that you can easily vectorize setting pixels in an image, or locations in a matrix quickly. As such, make your grayscale image into a RGB image by stacking the image three times as a 3D matrix. If you recall, grayscale images in the RGB colour model have all of the red, green and blue channels the same. For example, gray would be(R,G,B) = (128,128,128)
.Let's call your bifurcation points as
bifur
and terminations asterm
and are in that 2D matrix format I specified earlier. As such, do something like this:Let's walk through this code slowly. I first figure out the linear indices of where the bifurcation and termination points are in the image. What I do next is create red, green and blue channels that are all copies of the original image. After this, I access each colour channel and mark the bifurcation and termination points with different colours. For the bifurcation points, I made them purely red or
(R,G,B) = (255,0,0)
. For the termination points, I made them purely green or(R,G,B) = (0,255,0)
. Once I set the colours for the points, I create a colour image by stacking the channels together withcat
, and specifically choosing the third dimension. I finally show the image in the end.What you may also have to play with is the size of the markings on the image. As you can see, the pixels that are marked are just the single pixels themselves, and depending on the resolution of your image, you may or may not be able to see them properly in the image. As such, I would recommend you mark the pixels within a grid surrounding the original point. Perhaps you can make this a 5 x 5 grid surrounding the pixel of interest. With this, perhaps make a
for
loop for each point and mark a 5 x 5 pixel grid that surrounds this point. I'm also going to assume that your markings are sufficiently well inside the image so that we don't risk drawing the grid out of bounds. So the code would be modified like so:What has changed is the beginning of the code. For each point that we have for the bifurcation and the termination points, I use
meshgrid
to determine a 5 x 5 grid of points that surround each relevant pixel, then generate the linear indices for each point within the 5 x 5 grid. I then add this into one final array for both so that we can carry out the same marking logic we saw above.You'll have to play around with the colours if you want them to be other than red and green, but this should be something for you to start with. If you want a list of possible colours with the RGB model, a nice tool is the RGB colour picker where you figure out which colour you want, and it gives you the RGB values to replicate that colour.
Good luck!