News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Fast median algorithm

Started by guga, July 18, 2020, 02:22:35 AM

Previous topic - Next topic

Siekmanski

Creative coders use backward thinking techniques as a strategy.

guga

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Siekmanski

That's not okay.
Work to do....  :biggrin:
Creative coders use backward thinking techniques as a strategy.

guga

 :rofl: :rofl: :rofl:


This is with the version i did with the normalization. (This one needs a small fix. It is the  outdated version i used to compute the Sobel alone and not insid ethe main routine of the watermark remover. I´ll later join them both)

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Siekmanski

That's how it supposed to be.  :thumbsup:
Your post of my distorted image gave me a hint, it probably is the routine that draws it to screen.
I'll have a look tomorrow.
Creative coders use backward thinking techniques as a strategy.

guga

Hi Marinus

Finished analyzing the Laplace algorithm and this Lambert W Function. I succeeded to create this W function (with SSE2  :tongue: :tongue: :tongue:)  and i´ll give a try to see if it is worthfull to use laplace as an edge detector. I also implemented a log and exp function using SSE2, but the code is a kinda mess. So i´ll pout them later (here on on another thread to we test the speed :) )

Attached is a tutorial i wrote about this Laplace stuff to don´t forget what i´m doing :mrgreen: :mrgreen: :mrgreen:
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

Hi Marinus


I-´m not sure if i implemented this correctly, but...if i did, then....this is what Laplace results


Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Siekmanski

Hi Gustavo,

Great.  :cool:
I will digest the information you wrote, later this week.
Have a busy week ahead, so less time for coding.
Creative coders use backward thinking techniques as a strategy.

guga

No problem  :thumbsup: :thumbsup: :thumbsup:

I´m still trying to understand this whole laplace concept. The result using is 2-D Log function with Gaussian (without those matrices) is a sort of a mask. So i don´t know if i should use these 256 new values as a 16x16 matrix (that will be biased on each image) or if i should try to search the pixel values and compare with the results of the table (This is what i did, in fact).

I´m watching these videos
https://www.youtube.com/watch?v=kJKgCwUzkmc
https://www.youtube.com/watch?v=zQKNVept4bU

to try to understand.

Well.. at leats i got that damn W lambert function working with SSE. Despite the results i´ve got, the algo is pretty fast :bgrin: :bgrin: :bgrin:
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Siekmanski

Cool.

So, you're in love now with SSE...  :bgrin:
Maybe it is possible to transfer it into a matrix with pre-calculated coefficients???
Creative coders use backward thinking techniques as a strategy.

Siekmanski

Just watched the first video, it shows the coefficients for the 3*3 matrix.
As I understand it, it's used as a filter.
If so, it has to be used in a step before you apply the Sobel operations.

Creative coders use backward thinking techniques as a strategy.

guga

Yes, i´m liking to learn SSE :bgrin: :bgrin: :bgrin:

A bit painful at 1st, but the results are great.

What i did not understood is what a hell is this thing doing ?



I succeeded to create a formula and also made a function to work with this W Lambert stuff. But, what i did was assume that Log(x,y) = 0 to 255 and i´m not sure if it´s correct to do this way.  The resultant image is a sort of a mask but i´m not sure if all i did was correct. I tried to not use the matrix values and go straight to this formula.

The result was 256 values i used as a table, but i have no idea if it´s correct to do that way.

What´s log(x,y) all about ? I know what is log(x*y), log(x/y) etc, but with a ",", i have no idea. :greensml: :greensml: :greensml:


And also, the above formula is different from the one below:
https://academic.mu.edu/phys/matthysd/web226/Lab02.htm



Here it uses a power of 4 to calculate the Standard deviation, but on the image it displays a power of 2  :sad: :sad: :sad:
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

Ok, i guess i found how this stuff really works.

It´s used a a kernel generator, in fact

https://www.geeksforgeeks.org/gaussian-filter-generation-c
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

daydreamer

Quote from: Siekmanski on August 10, 2020, 09:02:06 PM
Cool.

So, you're in love now with SSE...  :bgrin:
Maybe it is possible to transfer it into a matrix with pre-calculated coefficients???
learn from RCP** instructions the backward math:way of faster coding together with replace x DIV** coefficients to x MUL** 1/coeffcients with upto REAL8 precisicion
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

Siekmanski

#209
Thinking it over, I think we can skip the overcomplicated approach.
We are not trying to get the highest accuracy.
Not an issue with only 3 coefficients.
Let me try to explain what I mean.

Let's think backwards:

The whole idea is to find coefficients for a lowpass filter.
The choices are, how do we want the curve to behave.
In other words, what type of filter.

filter example in 1 dimension:  [ -0.5 1.0 -0.5 ]

For the computation of a 3*3 matrix we only need 3 main coefficients, which represents a 2D first second order filter.

The Laplace filter uses the Standard Deviation to calculate the curve properties.

For 2D Laplace filter, it turns out to be these coefficients:
Very effective for the edge detecting routines. ( you see the cross in it? )

in 2 dimensions:

[ 0  1  0 ]
[ 1 -4  1 ]
[ 0  1  0 ]

1+1+1+1-4= 0

or try something like this:

[ 1  1  1 ]
[ 1 -8  1 ]
[ 1  1  1 ]

1+1+1+1+1+1+1+1-8= 0

With so few coefficients you could create your own filter type, by experimenting with the values.
As long as the surrounding values add up to zero including the middle value, you have created a filter with your own roll-off factor.

This could be a nice one too:

[ 0.5  1  0.5 ]
[ 1   -6  1    ]
[ 0.5  1  0.5 ]
Creative coders use backward thinking techniques as a strategy.