Ask Your Question

Greycloud's profile - activity

2020-03-17 04:41:16 -0600 received badge  Supporter (source)
2020-03-17 04:41:10 -0600 marked best answer Truncate and Normalize image

Is there a way to truncate and normalize an image in one step?

e.g. linearly map values from 50-100 to 0-255 ?

I can do it manually but of course its slow...

 byte range = (byte) (UpperThreshold - LowerThreshold);
            double f = (1.0 / (double) range) * 255;
            var copy = scan.Clone();
            for (int x = 0; x < copy.Cols; x++) {// todo this needs to be in native openCV to be fast enough for use
                for (int y = 0; y < copy.Rows; y++) {
                    byte v = copy.At<byte>(y, x);
                    double d = v;
                    d =  (d - LowerThreshold) * f;
                    if (d < 0) d = 0;
                    if (d > 255) d = 255;
                    v = (byte) d;
                    copy.Set<byte>(y,x,v);
                }
            }

            return copy;
2020-03-17 04:41:10 -0600 received badge  Scholar (source)
2020-03-17 04:41:06 -0600 commented answer Truncate and Normalize image

Epic, runtime reduced from 5000ms to 31ms Thank you @berak :)

2020-03-16 10:01:39 -0600 commented answer Truncate and Normalize image

as i understand it this will map the Min and Max values of my image to 0-255. Rather i want to map values between 50-100

2020-03-16 10:00:48 -0600 commented answer Truncate and Normalize image

as i understand it this will map the Min and Max values of my image to 0-255. Rather i want to map values between 50-100

2020-03-16 09:07:52 -0600 asked a question Truncate and Normalize image

Truncate and Normalize image Is there a way to truncate and normalize an image in one step? e.g. linearly map values