Apply blur to a 'FrameOval'?

6 views (last 30 days)
Elric Elias
Elric Elias on 7 Sep 2019
Answered: Rajani Mishra on 13 Sep 2019
I'm trying to draw an ellipse to a monitor, but I'd like the ellipse to have blurred edges. My current code (below) draws the ellipse to the specified screen, but the edges of the ellipse are sharp. Ideally, I'd like to apply a Gaussian blur to the edges of the ellipse (as imgaussfilt would, except that the target is not an image file).
The first two sections (below) simply prep the screen; no problems there. The last section draws and displays the shape. It is that shape that I'd like to apply a Gaussian blur to. This is for a vision science experiment. Ideas?
%% Prep Screen
gray = [171, 171, 171];
screens=Screen('Screens');
whichScreen=max(Screen('Screens'));
Screen('Preference', 'SkipSyncTests', 0);
[theWindow,theRect]=Screen('OpenWindow',whichScreen, gray, [0 0 800 600]);
[centerX, centerY] = RectCenter(theRect);
%% Screen Locations
wid = 120;
heit = 120;
halfwid = .5*wid;
halfheit = .5*heit;
[XC, YC] = RectCenter(theRect);
Loc1 = [XC-halfwid, YC - halfheit, XC + halfwid, YC + halfheit];
%% Display Shape
Ellipse = Screen('OpenOffScreenWindow',theWindow, gray); %use this
Screen('FrameOval', Ellipse, [130 130 130], [Loc1], 10);
Screen('DrawTexture', theWindow, Ellipse);
Screen('Flip', theWindow);
WaitSecs(1);
close 'all';
sca

Answers (1)

Rajani Mishra
Rajani Mishra on 13 Sep 2019
Hi,
Psychtoolbox is an open community that interfaces between MATLAB and the computer hardware. "Screen" is a function of that toolbox. Yes, you cannot apply Gaussian blur on shapes made by "Screen" function, as Gaussian blur is available for images. For blurring the edges you can use a subfunction "DrawTexture" of Screen command in Psychtoolbox with the proper arguments that can help in blurring.
As you also have used that subfunction in your code. I think changing the "FilterMode" argument of that subfunction will help in blurring the edges. FilterMode value will help in drawing the blurred textures.
You can also refer to the following documentation for more information:
Hope this helps!

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!