Now we also want to look for top-right, bottom-left and bottom-right corners, so we need to rotate the pattern, which ImageMagick handily does when you add the > flag: convert sample.dcm -threshold 90% \ That would be like this in the Terminal: convert sample.dcm -threshold 90% \ Hopefully you can see the top left corner of a white rectangle there. So, if we want to look for the top-left corner of a white rectangle on a black background, and we use 0 to mean "this pixel must be black", 1 to mean "this pixel must be white" and - to mean "we don't care", we would use this pattern: 0 0 0 0 0 Basically, you threshold your image to pure black and white - at around 90% say, and then you look for specific shapes, such as the corner markers on the label. If the simple threshold doesn't work for your images, I would look at "Hit and Miss Morphology". Of course, if the sample image is not representative, you may have to work harder. I prefer ImageMagick at the command-line, so I would do this: convert sample.dcm -threshold 99.99% -negate mask.pngĬonvert sample.dcm mask.png -compose darken -composite result.jpg Looking at the actual pixel values of the image you supplied, you can see that the marker is almost (99.99%) pure white and this doesn't occur elsewhere in the image so you can isolate it with a simple 99.99% threshold.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |