Ask Your Question
0

How to change gabor wavelet's colors

asked 2015-11-25 14:56:22 -0600

Tatev gravatar image

updated 2015-11-25 23:57:10 -0600

I draw gabor wavelets using this code

        Mat kernel = Imgproc.getGaborKernel(new Size(kernel_size, kernel_size), sigma, theta, lambda, gamma, Math.PI / 2.0, CvType.CV_64F);
        Mat normalized = new Mat();
        Core.normalize(kernel, normalized, 0, 255, Core.NORM_MINMAX);

This is what i have.

image description

I wander how I can draw it with other colors. I tried tried to replace for example background gray color with another color,but by just replacing I lost gabor effects.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-11-26 03:49:28 -0600

kbarni gravatar image

updated 2015-11-26 03:59:14 -0600

berak gravatar image

If you need coloring for display, you have to create a copy of the Mat, then convert it to a three channel image (type CV_8UC3) and play with the channels. Don't touch the original kernel, because it won't work after.

But probably you want only to apply a color map. This is the simplest solution for this problem.

Here is what you should do:

Mat kernel_byte = new Mat(), kernel_color = new Mat();
kernel.convertTo(kernel_byte,CV_8U,128,128);   // check the last two parameters
                                               // for correct normalization
Imgproc.applyColorMap(kernel_byte, kernel_color, Imgproc.COLORMAP_JET);

Here is a tutorial about color maps: Tutorial

edit flag offensive delete link more

Comments

1

*opencv3 only (for the java version)

berak gravatar imageberak ( 2015-11-26 04:00:12 -0600 )edit

Thanks for the corrections :)

kbarni gravatar imagekbarni ( 2015-11-26 04:53:56 -0600 )edit

@berak, your comment is invalid: http://docs.opencv.org/2.4/modules/co... so we should remove it? :D

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-27 05:09:21 -0600 )edit
1

great! Thank you :)

Tatev gravatar imageTatev ( 2015-11-27 05:10:49 -0600 )edit

I want to ask one more question. I found that to create custom color map in c++ they define unsigned char arrays then pass to Mat constructor, while in java the constructor expects argument type of scalar. Here is the link https://github.com/spmallick/learnope... Do you know if there is a way to convert those arrays, or maybe I should define r,g,b-is in another way

Tatev gravatar imageTatev ( 2015-11-27 05:12:32 -0600 )edit
1

@StevenPuttemans - unfortunately not available in java 2.4

on the other hand, it should not be too difficult, rolling your own LUT

berak gravatar imageberak ( 2015-11-27 06:29:47 -0600 )edit

Aha okay, thanks for the heads up!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-11-27 08:25:06 -0600 )edit

This answer explains how to create your own color map: http://answers.opencv.org/question/50...

kbarni gravatar imagekbarni ( 2015-12-10 02:04:10 -0600 )edit

thank you :)

Tatev gravatar imageTatev ( 2015-12-16 02:34:46 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-25 14:56:22 -0600

Seen: 425 times

Last updated: Nov 26 '15