Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Getting pixels  (Read 3409 times)

0 Members and 2 Guests are viewing this topic.

Tommeh

  • Newbie
  • *
  • Posts: 3
    • View Profile
Getting pixels
« on: April 13, 2009, 05:10:23 am »
I am building an app that takes input from animations/webcam/video files and converts it down to low resolution and greyscale to send to an external LED matrix.

Any tips/pointers as how to greyscale the video output and get it into a matrix (multidimensional array)?

I'm not just looking for an answer, but a point in the right direction would be greatly appreciated.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Getting pixels
« Reply #1 on: April 13, 2009, 09:22:05 am »
[I'm not an expert.]

Grey means same value for red, green and blue.

So, why not taking an average from this three value of one pixel to "greyize" it ?
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Getting pixels
« Reply #2 on: April 13, 2009, 09:36:53 am »
The best formula is the following:
grey = 0.3 * red + 0.59 * green + 0.11 * blue

It takes in account how the human eye sees the intensity of each component (green is much more brighter than blue).
Laurent Gomila - SFML developer

Tommeh

  • Newbie
  • *
  • Posts: 3
    • View Profile
Getting pixels
« Reply #3 on: April 13, 2009, 09:58:44 am »
Sorry, I should have been more specific.
Using a normal image and converting it to greyscale (via matricies/loops/whatever) is too slow for realtime, maybe it was just the way I was doing it...

It uses huge amounts of CPU when even crappy free webcam apps can convert the webcam input to greyscale (or perform many other effects) pretty easily without being too taxing on the CPU.

Also, what I have no clue about is how can I actually access the video output information of a SFML window?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Getting pixels
« Reply #4 on: April 13, 2009, 10:18:07 am »
Usually, this kind of filters is part of the video API, and thus can be highly optimized. What API are you using to capture the webcam output?
Laurent Gomila - SFML developer

Tommeh

  • Newbie
  • *
  • Posts: 3
    • View Profile
Getting pixels
« Reply #5 on: April 13, 2009, 06:17:05 pm »
Im using windows so I guess that means my Video API is directshow?
I was hoping to avoid using directshow since building it with mingw32 is hell.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Getting pixels
« Reply #6 on: April 13, 2009, 06:23:28 pm »
If it's DirectShow, I'm pretty sure you have a filter for that. You should find a good documentation or tutorial for it.
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Getting pixels
« Reply #7 on: April 14, 2009, 01:40:33 am »
Or just use a shader.