algorithm - Detecting individual images in an array of images -
i'm building photographic film scanner. electronic hardware done have finish mechanical advance mechanism i'm done.
i'm using line scan sensor it's 1 pixel width 2000 height. data stream sending pc on usb ftdi fifo bridge 1 byte values of pixels. scanner pull through entire strip of 36 frames end scanning entire strip. beginning i'm willing manually split them in photoshop implement in program me. i'm using c++ in vs. so, need find way pc detect near black strips in between images on film, isolate images , save them individual files.
could give me advice this?
that sounds pretty simple compared things you've implemented;
- calculate average pixel value per row, , call resulting signal
s(n)
(n
being row number). - set threshold
s(n)
, setting below threshold 0 , above 1 - assuming don't know exact pixel height of black bars , negatives, search periodicities in
s(n)
. describe in following total overkill, that's how roll:- use fftw calculate discrete fourier transform of
s(n)
, calls(f)
(f
being frequency, i.e. 1/period). - find
argmax(abs(s(f)))
;f
represents distance between 2 black bars:number of rows
/f
bar distance. s(f)
complex, , has argument;arctan(imag(s(f_max))/real(s(f_max)))*number of rows
give position of bars.
- use fftw calculate discrete fourier transform of
- to calculate width of bars, same second highest peak of
abs(s(f))
, it'll easier count average length of 0 around calculated center positions of black bars. - to exact width of image strip, take pixels in image border may lie:
r_left(x)
signal representing few pixels in actual image might border filmstrip material,x
being coordinate along row). now, use simplistic high pass filter (e.g.f(x):= r_left(x)-r_left(x-1)
) find sharpest edge in region (argmax(abs(f(x)))
). use average of these edges border location.
by way, if want write source block takes scanned image input , outputs stream of pixel row vectors, using gnu radio offer nice method of having flow graph of connected signal processing blocks want, without having care getting data b.
i forgot add: use resulting coordinates opencv, or other library capable of reading images , specifying sub-images coordinates saving new images.
Comments
Post a Comment