Tuesday, July 23, 2024
HomeMatlabSmall-Peak Suppression with the H-Maxima Remodel » Steve on Picture Processing with...

# Small-Peak Suppression with the H-Maxima Remodel » Steve on Picture Processing with MATLAB

Final time, I launched the thought of a regional most. As we speak, I need to add an idea that makes the regional most extra helpful: suppressing very small native maxima, probably current solely due to noise, which might be are unimportant, earlier than figuring out the regional maxima. This “small peak suppression” may be achieved utilizing one thing referred to as the h-maxima rework. The capabilities of curiosity at the moment: imregionalmax, imhmax, imextendedmax, imregionalmin, imhmin, and imextendedmin.

Let’s get there by beginning as soon as once more with the definition of regional most: a related element of pixels with a continuing worth h, the place each pixel that’s neighbor to that related element has a price that’s decrease than h. I would wish to elaborate on that utilizing a one-dimensional instance.

grid on

I am going to use dilation and erosion to establish curve samples which might be on plateaus.

plateau_mask = (y == imdilate(y,[1 1 1])) & (y == imerode(y,[1 1 1]));

maintain off

Listed below are some zoomed-in views that illustrate three sorts of plateaus which might be of curiosity.

textual content(20,52,“regional most”,HorizontalAlignment=“middle”)

textual content(47,14,[“regional” “minimum”],HorizontalAlignment = “middle”,

VerticalAlignment = “prime”)

textual content(55,14,[“regional” “minimum”],HorizontalAlignment = “middle”,

VerticalAlignment = “prime”)

textual content(51,19,[“regional” “maximum”],HorizontalAlignment = “middle”,

VerticalAlignment = “backside”)

textual content(66,83,“plateau”,HorizontalAlignment = “proper”)

textual content(64,79,[“not a regional max” “not a regional min”],

HorizontalAlignment = “left”, VerticalAlignment = “prime”)

As I confirmed final time, the operate imregionalmax identifies the placement of regional maxima. These may be particular person samples or pixels, or they are often plateaus. Have a look:

axis([-5 105 -0.05 1.05])

title(“Output of imregionalmax”)

title(“Regional maxima plateaus”)

The curve I have been experimenting with is comparatively easy, with plateaus which might be fully flat. Sadly, the imregionalmax is considerably much less helpful when the enter is even a bit of noisy. That is as a result of noise introduces small native maxima in lots of locations, and imregionalmax picks up even the tiniest native maxima. Let’s attempt it. If I add a really small quantity of noise, you’ll be able to’t even see it within the plot:

yn = y + (0.01 * randn(dimension(y)));

grid on

However now the output of imregionalmax seems to be fully totally different.

grid on

Now, solely a scattering of samples on the broad plateaus are recognized as regional maxima, and a pattern on the small “shoulder” plateau is marked as a regional most the place it wasn’t earlier than. We’ve got to zoom in fairly far to see why that is taking place.

axis([5 20 49.8 50.1])

axis([62 67 79.9 80.2])

You may see that the added noise is introducing tiny native maxima in varied locations, and that’s throwing imregionalmax off the scent from what we might like for it to do.

## imhmax

And this is the place the operate imhmax comes into play. It computes one thing referred to as the h-maxima rework. This operation basically suppresses any native maxima which might be lower than a sure top (h) above their rapid environment. As an instance, for instance, that we’re solely fascinated with native or regional maxima which have a top of greater than 5 models above their rapid environment. We accomplish this by calling imhmax like this:

legend([“original” “h-maxima transform”])

Within the output of imhmax, the broad peaks have been flattened out, and the small peak within the center, which has a top of solely 3 above its environment, has been flattened out and eradicated. Now let’s attempt imregionalmax once more.

grid on

With that computation, now we have recognized solely the peaks which might be considerably greater than what’s round them, and that is usually what we’re fascinated with. Discover that the h-maxima rework spreads out the height a bit, and so the end result proven above is selecting out a little bit of the “shoulders” to the left and proper of every broad plateau. We may do some post-processing to right that, if needed.

There may be one other operate, imextendedmax, that merely combines the h-maxima rework and regional maxima steps right into a single operate. Should you’re fascinated with minima as a substitute, then you should utilize the upside-down variations of those capabilities: imhmin, imregionalmin, and imextendedmin.

You probably have discovered fascinating makes use of for these capabilities in your personal work, I would love to listen to about it, so please depart a remark.

### Utility operate

operate y = peaksAndPlateaus

f = @(x) min(max(1-abs(x/5),0),0.5);

g1 = @(x) 100*f((x-20)/5);

g2 = @(x) 200*f((x-80)/5);

g3 = @(x) 30*f((x-50)/3);

g = @(x) g1(x) + g2(x) + g3(x) + g4(x) + g5(x);

RELATED ARTICLES