# Retrieve real wood fiber structure from image

**URL:** <https://discourse.processing.org/t/retrieve-real-wood-fiber-structure-from-image/1731>\
**Category:** Coding Questions\
**Created:** [July 13, 2018, 5:44am UTC](https://discourse.processing.org/t/retrieve-real-wood-fiber-structure-from-image/1731 "2018-07-13T05:44:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Han](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/han/32/734_2.png) [@Han](https://discourse.processing.org/u/Han)\
**Post date:** [July 13, 2018, 5:44am UTC](https://discourse.processing.org/t/retrieve-real-wood-fiber-structure-from-image/1731/1 "2018-07-13T05:44:57Z")

</div>

I am going to write a program to process an image with very fine wood fibers in it. Please have a look at this for a quick idea - [http://alturl.com/7jnuh](http://alturl.com/7jnuh)

What I want to do is keep only the fiber lines in a black and white image and discard other features and colors. How can I use OpenCV to it? Thanks.

---

<div class="post-metadata">

**Author:** ![MxFxM](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MxFxM](https://discourse.processing.org/u/MxFxM)\
**Post date:** [July 13, 2018, 9:21am UTC](https://discourse.processing.org/t/retrieve-real-wood-fiber-structure-from-image/1731/2 "2018-07-13T09:21:26Z")

</div>

Not sure. I would get the pixels and then figure out if they are dark or light and then go from there I guess. Maybe compare them to thier neighbours?

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 13, 2018, 4:30pm UTC](https://discourse.processing.org/t/retrieve-real-wood-fiber-structure-from-image/1731/3 "2018-07-13T16:30:41Z")

</div>

boofCV has a [line detector](https://boofcv.org/index.php?title=Example_Detect_Lines). You can install it via the Contributor manager in the PDE and try its examples.

Kf

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [July 13, 2018, 5:35pm UTC](https://discourse.processing.org/t/retrieve-real-wood-fiber-structure-from-image/1731/4 "2018-07-13T17:35:38Z")

</div>

If all you need is an image, you can use the built in filters: [https://processing.org/reference/filter\_.html](https://processing.org/reference/filter_.html)

If you need more control, I can recommend using shaders like this one: [https://github.com/SableRaf/Filters4Processing/tree/master/sketches/ContrastSaturationBrightness](https://github.com/SableRaf/Filters4Processing/tree/master/sketches/ContrastSaturationBrightness)

This is an example result:

 ![28](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/1X/b708c5105bd57c5dc13df56dff0f1baf1587226a.png)

And the modified code for the PDE

```auto

PShader myFilter;
PImage myImage;

void setup() {

  size( 474, 474, P2D );
  
  myImage = loadImage( "th.jpg" );
  myFilter = loadShader( "shader.glsl" );

}

void draw() {

  background(0);

  // Draw the image on the scene
  image( myImage, 0, 0 );
  
  // For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
  float c = 2.6;
  float s = 0.0;
  float b = 2.2;

  // Pass the parameters to the shader
  myFilter.set( "contrast", c );
  myFilter.set( "saturation", s );
  myFilter.set( "brightness", b );

  // Applies the shader to everything that has already been drawn
  filter( myFilter );

}

```

Download the whole thing here: [https://we.tl/44hfxifLXC](https://we.tl/44hfxifLXC) (link will expire in 7 days)

---

<div class="post-metadata">

**Author:** ![Han](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/han/32/734_2.png) [@Han](https://discourse.processing.org/u/Han)\
**Post date:** [July 17, 2018, 2:22am UTC](https://discourse.processing.org/t/retrieve-real-wood-fiber-structure-from-image/1731/5 "2018-07-17T02:22:37Z")

</div>

Thank you all for your replies.
