Is there a way how to do the following in IM 6.7.5-1 2012-01-28 Q8?
When I have image with some lines like this:
I would like to detect places where the lines are crossed. To be more exact, I am not interested in the places which are crossed...
This is related to my previous thread viewtopic.php?f=1&t=29790&p=133933#p133933 (I asked how to get pixels from some specific area in the image; the area is defined by coordinates). Now, if it is possible to detect the places where is bigger dencity of blue pixels by converting image like this:
You should see that the area where the lines are crossed are slightly more red than the next parts.
Then I would select the place where the colors are acumulated:
(I had to enlarge the image coz the colors were not saved in low resolution)
Then I expand the selection and just delete it
and finally I want to keep the previous task with color selection, (but this time different color). So in the result I will have this:
Which is near location where I originally clicked on a blue line.
To sum it up:
My goel is to get certain part of image based on coordinate, as I asked in previous thread,
and then to remove the places where the pixels are accumulated. Then repeat the previous to get the part of line. My target is to get mask, not the original color.
How to detect amount of pixels of some color in area?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to detect amount of pixels of some color in area?
To find the crossing, you could skeletonise then find the junction. See http://www.imagemagick.org/Usage/morphology/
Another method is to blur, and find the darkest area.
Another method is to blur, and find the darkest area.
Code: Select all
convert 2yw64g6.jpg -virtual-pixel White -blur 0x10 -colorspace Gray -auto-level -threshold 5% b.png
snibgo's IM pages: im.snibgo.com
Re: How to detect amount of pixels of some color in area?
I have tested your code:
https://1.bp.blogspot.com/-RifbYC9NIUg/ ... /paths.jpg
The problem is that is does not found the junctions except one.
One would expect that if I set 0x10 as the size of brush it should work. If I set 0x6 then if finds but not the correct area (the result is too small).
However, this should work:
But it does not work to my image, it does not change it at all (looks so). Nor in grayscale.
Edit:
However new problem arises. What if I have this image of route containing gaps:
I need to enlarge the image before I will do thinning. What is better method? Blur it and levels? Or Thicken? The Thicken seems to take too much time and with no result.
blur and threshold is much faster but it is not perfect because some lines were connected. So the bottom routes joined in one fat line
This is result:
Then when I do the thinning:
I found one route bellow instead 1...
Seems like it took 7s to convert the image 1024x728px.
So I tried different command:
It seems a bit faster
What if I just make small blur:
how could I get rid of the small black gaps?
Now trying to solve the detection of the rectangles to blur the image with routes. It takes +55 minutes for 1024x768px.
https://1.bp.blogspot.com/-RifbYC9NIUg/ ... /paths.jpg
The problem is that is does not found the junctions except one.
Code: Select all
convert paths.jpg -virtual-pixel White -blur 0x9 -colorspace Gray -auto-level -threshold 5%% junction_width_9.png
convert paths.jpg -virtual-pixel White -blur 0x10 -colorspace Gray -auto-level -threshold 5%% junction_width_10.png
However, this should work:
Code: Select all
convert lines.gif -morphology HMT LineJunctions hmt_junctions.gif
But it does not work to my image, it does not change it at all (looks so). Nor in grayscale.
Edit:
Code: Select all
I see the problem. What I needed to do:
convert paths.jpg -fuzz 10%% -fill black +opaque "#8697ff" -fuzz 10%% -fill white -opaque "#8697ff" paths_mask.gif
convert paths_mask.gif -morphology Thinning:-1 Skeleton paths_thinned.gif
I need to enlarge the image before I will do thinning. What is better method? Blur it and levels? Or Thicken? The Thicken seems to take too much time and with no result.
blur and threshold is much faster but it is not perfect because some lines were connected. So the bottom routes joined in one fat line
Code: Select all
convert highway_mask.gif -blur 0x4.0 -threshold 25%% highway_threshold_40.png
Then when I do the thinning:
Code: Select all
convert highway_threshold_40.png -morphology Thinning:-1 Skeleton highway_thinned.gif
Seems like it took 7s to convert the image 1024x728px.
So I tried different command:
Code: Select all
convert highway_threshold_40.png -morphology Thinning:-1 Skeleton highway_thinned.gif
It seems a bit faster
What if I just make small blur:
how could I get rid of the small black gaps?
Now trying to solve the detection of the rectangles to blur the image with routes. It takes +55 minutes for 1024x768px.
Code: Select all
compare -metric RMSE -subimage-search highway_mask.png small_img_board_1.png result.png
Re: How to detect amount of pixels of some color in area?
more clean:
Code: Select all
convert highway_thinned.gif -channel RGB -morphology Thinning:-1 'LineEnds:1>' result.png