Page 1 of 1

Brick wall

Posted: 2016-01-07T14:40:23-07:00
by alduin
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?

Re: Brick wall

Posted: 2016-01-07T20:13:39-07:00
by fmw42
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. :wink: 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.

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

Posted: 2016-01-08T09:04:16-07:00
by alduin
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?

Re: Brick wall

Posted: 2016-01-08T11:33:37-07:00
by GeeMack
alduin wrote:I have a photo from which I'd like to extract the lines from the bricks.
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...

Code: Select all

convert xyyu4f8.jpg -background none -colorspace gray -modulate 80 -colors 2 -normalize -transparent black result.png
Or depending on what you're trying to achieve, maybe starting from scratch would be a better approach. :wink:

Code: Select all

convert -background none -size 48x192 tile:pattern:bricks -negate -scale 300%x200% -transparent black result.png

Re: Brick wall

Posted: 2016-01-08T11:35:41-07:00
by fmw42
The verticals are probably not long enough nor lined up well, but you can try scaling to one row rather than one column.

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
When I try that, I get only one vertical line.

Re: Brick wall

Posted: 2016-01-08T11:44:24-07:00
by fmw42
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