Detect min/max position

  • Hello,
    I can't find a way to find the location of a min/max data in a data1D or data2D.

    For instance, imagine I want to implement an OTSU binarization on 8-bit images. The idea is to compute an histogram, then find the good threshold maximizing the separation of pixels into two classes. I could just compute in parallel the 256 possible threshold separations, and select the one maximizing some formula. But I would need to detect a max and apply it to some branch select. Is it possible ?

    Other use case : I perform a convolution with a kernel, and want to find the location of the maximum result of the convoution to perform some work around that location.

    Is it possible with standard operators ?

  • MaxPos.pngHello Pierre,

    To get the location of a global/local Max or Min value you can use RowMax, ColMax, FrameMax. These operators have a second output that is binary 1(true) in case a new extreme value is found. Use Register to keep the X/Y coordinate of the new extreme value.

    If you want to get a Max peak in a histogram simply use the Histogram(preset: 1 line) output as input for FrameMax.

    In case a new extreme value is found use the operators Coordinate_X/Y and register to keep those values in case.

    Some additional details will be necessary for further processing: Please have a look the attached VA example design.

    Same approach for Col- and Row-Max/Min.



      (7.38 kB, downloaded 1 times, last: )

    Björn Rudde

    Senior Technical Sales and

    Field Application Engineersiso-logo-animation.gif

  • Thanks.

    However, I still don't understand something about synchronization.

    Imagine (for the sake of simplicity, this is just an example) that I want to multiply each "pixel" of the histogram by the sum of all the values in the histogram.

    I can make a FIFO of 256 values to store the incoming histogram values, while making a "framesum" on a parallel link to compute the sum of all histogram values.
    But then, how can I apply the final sum to all the FIFO values ? I can't find which operator to use to "block" the FIFO output 255 times, so that once unblocked, the total sum is up-to-date and will be properly applied to the 256 stored values.
    I guess I have to use IsLastPixel and RemovePixel, but I can't make it work.

  • I finally succeeded.

    For instance, in the example of the previous message, where I wanted to multiply each pixel of the histogram by the sum of all values in the histogram, I found out that I can ;

    -on an out branch of the historgam, perform RowSum

    -on that branch, use "RemovePixel" for pixels 0-254, and keep pixel 255

    -replicate that last pixel 256 times

    -sync with the regular histogram output

    It seems to do exactly what I want.

    Now, I have a design that works (I have implemented an adaptive binarization based on histogram analysis).
    Simulation works, visual result on dummy images is OK, bandwidth analysis works up to 800 MB/s (for max and mean)

    But guess what ? Once compiled on the board, with a real camera, I just get no images. The DmaToPC never gets a frameIndex > 0.

    The board is a MicroEnable5 VD8-PoCL

    The camera runs at 1280x1024@50fps

    How can I investigate where the problem occurs ? Since the simulation works perfectly, I am very surprised.

  • I have added an ImageBuffer on the "original image" branch before the last sync operator. It seems to remove the deadlock that was not shown by the simulation.
    However, the bandwidth test now drops from 800MB/s to 600MB/s.