Reputation: 105
I'm building a photographic film scanner. The electronic hardware is done now I have to finish the mechanical advance mechanism then I'm almost done.
I'm using a line scan sensor so it's one pixel width by 2000 height. The data stream I will be sending to the PC over USB with a FTDI FIFO bridge will be just 1 byte values of the pixels. The scanner will pull through an entire strip of 36 frames so I will end up scanning the entire strip. For the beginning I'm willing to manually split them up in Photoshop but I would like to implement something in my program to do this for me. I'm using C++ in VS. So, basically I need to find a way for the PC to detect the near black strips in between the images on the film, isolate the images and save them as individual files.
Could someone give me some advice for this?
Upvotes: 2
Views: 98
Reputation: 36482
That sounds pretty simple compared to the things you've already implemented; you could
s(n)
(n
being the row number).s(n)
, setting everything below that threshold to 0 and everything above to 1s(n)
. What I describe in the following is total overkill, but that's how I roll:
s(n)
, call it S(f)
(f
being the frequency, i.e. 1/period). argmax(abs(S(f)))
; that f
represents the distance between two black bars: number of rows
/ f
is the bar distance. S(f)
is complex, and thus has an argument; arctan(imag(S(f_max))/real(S(f_max)))*number of rows
will give you the position of the bars.abs(S(f))
, but it'll probably be easier to just count the average length of 0 around the calculated center positions of the black bars.r_left(x)
would be the signal representing the few pixels in which the actual image might border to the filmstrip material, x
being the coordinate along that row). Now, use a simplistic high pass filter (e.g. f(x):= r_left(x)-r_left(x-1)
) to find the sharpest edge in that region (argmax(abs(f(x)))
). Use the average of these edges as the border location.By the way, if you want to write a source block that takes your scanned image as input and outputs a stream of pixel row vectors, using GNU Radio would offer you a nice method of having a flow graph of connected signal processing blocks that does exactly what you want, without you having to care about getting data from A to B.
I forgot to add: Use the resulting coordinates with something like openCV, or any other library capable of reading images and specifying sub-images by coordinates as well as saving to new images.
Upvotes: 2