I have a photo from which I'd like to extract the lines from the bricks.
http://i.imgur.com/xyyu4f8.jpg
I tried using Canny edge and hough lines without much success... Any advices?
Brick wall
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Brick wall
Your brick and mortar pattern is too "noisy" or rough to get much from any edge operator and the lines are not long and straight enough for Hough lines. So I guess you are "up against a brick wall" in solving this. Sorry, I could not resist the pun.
Best I can suggest is converting to white lines on black background, then scaling down to 1 column and then back up to the original size. Then thresholding and applying morphology thinning.
Best I can suggest is converting to white lines on black background, then scaling down to 1 column and then back up to the original size. Then thresholding and applying morphology thinning.
Code: Select all
convert xyyu4f8.jpg \
-fuzz 25% -fill black -opaque "#FA0000" \
-fill white +opaque black \
-scale 1x! -scale 94x294! \
-threshold 50% \
-morphology Thinning:-1 Skeleton \
result.png
Re: Brick wall
Nice pun!
This is great, I've tried the conversion you suggested and It's beyond my expecatation.
I just need to find a way to get the Vertical lines, any suggestions?
This is great, I've tried the conversion you suggested and It's beyond my expecatation.
I just need to find a way to get the Vertical lines, any suggestions?
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Brick wall
As fmw42 said, the original image is pretty poorly defined, so there's not much that can be done with it. If you want to isolate the mortar lines you could try changing it to just two shades of gray, force those to just black and white, and make the black transparent. Some tweaking of the brightness (-modulate 80) before reducing the number of colors might help bring out more of what you want, but probably not by much. Roughly something like this...alduin wrote:I have a photo from which I'd like to extract the lines from the bricks.
Code: Select all
convert xyyu4f8.jpg -background none -colorspace gray -modulate 80 -colors 2 -normalize -transparent black result.png
Code: Select all
convert -background none -size 48x192 tile:pattern:bricks -negate -scale 300%x200% -transparent black result.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Brick wall
The verticals are probably not long enough nor lined up well, but you can try scaling to one row rather than one column.
When I try that, I get only one vertical line.
Code: Select all
convert xyyu4f8.jpg \
-fuzz 25% -fill black -opaque "#FA0000" \
-fill white +opaque black \
-scale x1! -scale 94x294! \
-threshold 50% \
-morphology Thinning:-1 Skeleton \
result.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Brick wall
You can also do the following, but it will just show how rough the mortar is.
Code: Select all
convert xyyu4f8.jpg \
-fuzz 25% -fill black -opaque "#FA0000" \
-fill white +opaque black result.png