The minimum / maximum filter is applied by using four for the loop normally and with very inefficiency. {// yo loop} (// index3 and lefnius; structural element.net) for // <3>
Y (index 4
Although this approach is very inefficient as it again checks the previously checked values, then I am thinking that using the previously checked values on the next walk What are the methods to implement it?
Any assumption about the shape / point of an element's structure can be made.
Update: I am especially curious to know any insights in this way or the implementation:
I have been following this question for a while, hoping that someone can answer the answer, because I am considering the same problem .
Even my own efforts are there; I have not tested this, but I think you can repeat and corrosion with any structure element only by entering twice in each pixel:
Concepts: structure element Assume the kernel / a KxL rectangular and the image is an NXM rectangle assume that the K and L are weird.
The basic approach you have outlined is four for loops and takes time to complete O (K * L * N * M)
.
Often you want to spread the same with the same kernel, so time is multiplied with the desired number.
I have three basic ways to speed up the dispersion:
-
The extension by a KxL kernel is equal to the dispersion by a Kx1 kernel, after which the 1xL kernel You can do this in two steps with only three loops in the dispersion of O (k n m) and o (l n m)
-
However you can sharpen with the Kx1 kernel: You only need to use each pixel once to come Requires a special data structure, which is explained below. This allows you to make a single dispersion in O (nm), regardless of the kernel size
-
Repeated repetition by a Kx1 kernel is a large scale similarity Is equal to the kernel. If you spread the K bar with 1 Kx1 kernel, then it is equal to a single dispersion with
((K-1) * P + 1) x 1
kernel. So you can disperse repeating repetitions with any kernel size in single pass in O (nm) time.
Now for a detailed description of Step 2
You need to queue with the following properties:
- Push the element behind the queue in an element continuously.
- Pop an element from the front row in the constant time.
- Ask the current minimum or greatest element in the queue for continuous time.
How to prepare this type of queue is described in this stackflow answer: Unfortunately there is not a lot of pseudoscope, but the original idea sounds.
By using such a queue, you can calculate a Kx1 disposition in one pass:
emphasis (StructuringElement. Dy () == 1); Int kernel_half = (Element.dx (Structuring) - 1) / 2; (X & lt; dy) {// y for loop (x & lt; = kernel_half) {// start queue queue. Push (source (x, y)); } (X kernel_half) queue.Pop (); // Add the next pixel in the queue if the (x
Comments
Post a Comment