# Min, Max and Mathematical Morphology

## Min, Max and Mathematical Morphology

Hi,
The most basic operation in mathematical morphology is the union/intersect operation which, in binary (1-bit) images, is the OR/AND bitwise operation and in the grayscale generalization, the max/min operation.

IPP (IPL) supports the greater/less (ippiCompare_) than functions. This function returns a bit/byte binary mask of which pixels fullfil the condition.

However, this is a problematic approach since it requires multiple operations to produce the max/min image, i.e. the image in which each pixel is the maximum/minimum of the respective pixels of 2 input images.

Considering that most processors (ARM too) contain speacial instructions for such min=/max= operation without branches such functions seem somewhat inefficient.

Does IPP have or will it have such a max/min operation?
I believe it can be made exteremly efficient much more than the current greater/less functions.

15 posts / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.

the question is does IPP optimized code uses special CPU instructions? The answer is - yes, of course. We always try to use CPU hw capabilities if they can help us to reach better performance.

Regards,

Hi,

Actually, this wasn't really my question. Since as you say you use special CPU instruction, it seems starnge that there isn't one atomic operation for getting the min(max) of 2 images(arrays).

The current implementation requires keeping an intermidiate result mask e.g for later assignment. Though convenient for some things, other operation can benefit from avoiding this second image pass.

So, you talk about something like this:

ippiMin_8u_C1R(pSrc1,pSrc2,pDst),

where pDst[i[][j] = min(pSrc1[i][j],pSrc2[i][j])

Is that right?

Exactly!, and, of course, the in-place version and the max versions too.

Ok, now I understand, thank you. Well, we will consider this request.
If you did notsubmitted yet this request to Intel Premier Support, it would be nice to do it. So it will fall into our data base where it will be tracked.

Regards,

Sure. Will do.

Thanks,

By the way, have you seen ippsMinEvery/ippsMaxEvery API in ippSP library? Wesupport 16s/32s/32f data types for in-place operations, so you can use them for images at row-by-row basis.

Hmm.. I haven't seen this. You're right, I can use this for depths larger than 8-bit.

This is what I wanted for images too.

Thanks,

Ok, I'm gladthat this info was useful somehow:)

Please do not forget to submit request for new functionality through the premier support service. Of course, it does not mean we automatically accept it, but we will consider it for the next versions of IPP. You understand, it always some compromise between what we want to do and what we can, at least at this moment:)

Thank you,

Thanks,

Well, now I am happy:)

Well, now I am happy:)

Well, five years laster it seems that the requested function is still unavilable.

Hi,

Have you noticed bellow function :
ippiMinEvery_

It suport 8u, 16u, 16s, 32f type. Is this what your required?

Thanks,
Chao

Quoting - Chao Y (Intel)

Hi,

Have you noticed bellow function :
ippiMinEvery_

It suport 8u, 16u, 16s, 32f type. Is this what your required?

Thanks,
Chao

I am terribly sorry.
I assumed that that MinEvery_ should belongs to either arithmetic, filtering or comparing operations without looking through the manual.