1

I have a video that I shot for scientific purposes. I would like to measure the colour information in a single spot and export for example the RGB or CMYK values of that spot through every frame into a text file.

The video itself is a .MOV file which I colour-balanced with a white card. I just couldn't find any information on how to extract the information with any software. My university provides Adobe Photoshop in which I am able to open the video.

Does anyone know a software which enables me to extract that data? Or does someone know how I can do that with Photoshop?

2
  • 1
    A histogram is a representation of the distribution of channel values for the entire picture. You can't have a histogram of a single pixel. You might get better search results if you search for "point sample". en.wikipedia.org/wiki/Histogram
    – stib
    Commented May 24, 2018 at 10:50
  • Oh, sorry, that was a terminology mistake of mine. I am looking for the colour information in one spot, as for example the RGB information. Commented May 24, 2018 at 14:16

2 Answers 2

1

Using ffmpeg, a free command-line tool, you can do

ffmpeg -i in.mp4 -vf "crop=1:1:234:541:exact=1,tile=50x10,format=rgb24,histogram" out.png

A series of filters are run on the input video.

The crop filter takes each frame and extracts a 1x1 sized window i.e. a single pixel at co-ordinates (234,541) measured from top-left of frame. Numbering starts at 0.

The tile filter collects all of these single pixel frames into a single frame of dimensions 50x10. It is important that the product of these dimensions (500) match the total number of frames in the video. If it's greater, the difference will be black pixels added by the tile filter and throw off your histogram; if less, frames will be skipped. Worst case scenario, your frame count is prime, so you can either do Countx1 or MxN where M*N is count + 1.

The next filter converts the tile output to a RGB pixel format, since videos typically are YUV.

The histogram filter generates a graphical RGB histogram which is saved to a PNG. See the filter doc for options to change layout or image size.

1

The first thing I'd be looking at is Processing. There's a library that lets you read video, there's an example here that shows how to to sequentially grab frames from a video.

Then (instead of displaying the frame like it does in that example) you need to find the channel values for the spot which you could do by copying the frame to a PImage. Then the value of the pixel (x,y) is found in the PImage property pixels[x,y]. Finally use createWriter() to output the data to a file. You could even get fancy and use the mouse to control your sample point, and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.