Creating red-white gabors

Hi I would like some advice on creating a red-white gabber. I first created a texture of a monochrome gabor (using DriftDemo2 as reference), and then used [255 0 0] as modulateColour when drawing the texture, giving me a red-black gabor. I understand why I'm getting the black lines instead, but I'm not sure how to make the changes. I tried changing the parameters in the ProceduralGaborDemo, but still, I've only managed to get red-black gabors. Should I not be using a monochrome gabor in the first place? Or should I perhaps use a custom colourmap to change the monochrome gabor to a red-white one? Below is a snippet of the code. Any help would be much appreciated.  Thanks in advance.

    f = 0.2; %grating cycles/pixel;

    fr = 2*pi*f; %frequency in radians

    angle = 45;

    p = ceil(1/f);

    gratingsize = 16;

    visiblesize = 2*texsize;

    dstRect = [0 0 visiblesize visiblesize];

    x = meshgrid(-texsize:texsize+p,1); %2*texsize+p columns

    grating = grey+inc*cos(fr*x);

    gratingtex = Screen('MakeTexture', wPtr, grating);

    Screen('DrawTexture', wPtr, gratingtex, [], ovalLoc(:,i), angle*orient(i), [], [], [255 0 0]);




     

For me the most intuitive way would be to replicate a 2D grayscale grating in three color channels and set the red color channel to 1.

There is an excellent tutorial how to create Gabor patches with Matlab by Elliot Freeman:
http://www.icn.ucl.ac.uk/courses/MATLAB-Tutorials/Elliot_Freeman/html/gabor_tutorial.html

With two additional lines after
grating = sin( XYf + phaseRad); % make 2D sinewave

you can create a red-white grating which should be usable for your purpose:
grating = repmat(grating / 2 + 0.5, [1 1 3]); % Scale to 0-1 and make 3D
grating(:, :, 1) = 1; % Set red color channel to 1

Adjust the gauss matrix accordingly.

Best,
Andreas

Am 28.11.2013 um 10:56 schrieb icezland@...:

>
>
> Hi I would like some advice on creating a red-white gabber. I first created a texture of a monochrome gabor (using DriftDemo2 as reference), and then used [255 0 0] as modulateColour when drawing the texture, giving me a red-black gabor. I understand why I'm getting the black lines instead, but I'm not sure how to make the changes. I tried changing the parameters in the ProceduralGaborDemo, but still, I've only managed to get red-black gabors. Should I not be using a monochrome gabor in the first place? Or should I perhaps use a custom colourmap to change the monochrome gabor to a red-white one? Below is a snippet of the code. Any help would be much appreciated. Thanks in advance.
>
> f = 0.2; %grating cycles/pixel;
>
> fr = 2*pi*f; %frequency in radians
>
>
> angle = 45;
>
> p = ceil(1/f);
>
> gratingsize = 16;
>
> visiblesize = 2*texsize;
>
> dstRect = [0 0 visiblesize visiblesize];
>
> x = meshgrid(-texsize:texsize+p,1); %2*texsize+p columns
>
> grating = grey+inc*cos(fr*x);
>
> gratingtex = Screen('MakeTexture', wPtr, grating);
>
>
> Screen('DrawTexture', wPtr, gratingtex, [], ovalLoc(:,i), angle*orient(i), [], [], [255 0 0]);
>
>
>
>
>
>
>
>

I was able to display both red-white and green-white gratings at the same time but now I also wish to adjust the contrast the contrast of the gratings (eg. give the red-white gratings a darker or lighter shade of red). Adjusting the globalAlpha in DrawTexture changes the luminance, so it doesn't help. Do you have any solution? 


I tried another method, which goes like this:

1) Create grating matrix

2) Create custom colourmap for each grating which also allows me to adjust the contrast, eg. [contrast 0 0] for red-white grating

3) saving the grating as a tiff file with associated colourmap using imwrite function


The image showed what I wanted, but I'm not able to associate the grating matrix with the colourmap when drawing the texture. Is there a way to go about it?



Thanks a lot.

 



---In psychtoolbox@yahoogroups.com, <widmann@...> wrote:

For me the most intuitive way would be to replicate a 2D grayscale grating in three color channels and set the red color channel to 1.

There is an excellent tutorial how to create Gabor patches with Matlab by Elliot Freeman:
http://www.icn.ucl.ac.uk/courses/MATLAB-Tutorials/Elliot_Freeman/html/gabor_tutorial.html

With two additional lines after
grating = sin( XYf + phaseRad); % make 2D sinewave

you can create a red-white grating which should be usable for your purpose:
grating = repmat(grating / 2 + 0.5, [1 1 3]); % Scale to 0-1 and make 3D
grating(:, :, 1) = 1; % Set red color channel to 1

Adjust the gauss matrix accordingly.

Best,
Andreas

Am 28.11.2013 um 10:56 schrieb icezland@...:

>
>
> Hi I would like some advice on creating a red-white gabber. I first created a texture of a monochrome gabor (using DriftDemo2 as reference), and then used [255 0 0] as modulateColour when drawing the texture, giving me a red-black gabor. I understand why I'm getting the black lines instead, but I'm not sure how to make the changes. I tried changing the parameters in the ProceduralGaborDemo, but still, I've only managed to get red-black gabors. Should I not be using a monochrome gabor in the first place? Or should I perhaps use a custom colourmap to change the monochrome gabor to a red-white one? Below is a snippet of the code. Any help would be much appreciated. Thanks in advance.
>
> f = 0.2; %grating cycles/pixel;
>
> fr = 2*pi*f; %frequency in radians
>
>
> angle = 45;
>
> p = ceil(1/f);
>
> gratingsize = 16;
>
> visiblesize = 2*texsize;
>
> dstRect = [0 0 visiblesize visiblesize];
>
> x = meshgrid(-texsize:texsize+p,1); %2*texsize+p columns
>
> grating = grey+inc*cos(fr*x);
>
> gratingtex = Screen('MakeTexture', wPtr, grating);
>
>
> Screen('DrawTexture', wPtr, gratingtex, [], ovalLoc(:,i), angle*orient(i), [], [], [255 0 0]);
>
>
>
>
>
>
>
>