Ask Your Question

How to change gabor wavelet's colors

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

Tatev gravatar image

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

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

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

kbarni gravatar image

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

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



*opencv3 only (for the java version)

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

Thanks for the corrections :)

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

@berak, your comment is invalid: so we should remove it? :D

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

great! Thank you :)

Tatev gravatar imageTatev ( 2015-11-27 05:10:49 -0500 )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 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 -0500 )edit

@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 -0500 )edit

Aha okay, thanks for the heads up!

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

This answer explains how to create your own color map:

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

thank you :)

Tatev gravatar imageTatev ( 2015-12-16 02:34:46 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


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

Seen: 212 times

Last updated: Nov 26 '15