How can I generate Gabor patterns with specified contrasts and save them as pictures?

4 ビュー (過去 30 日間)
G GK
G GK 2015 年 12 月 22 日
回答済み: Sreeram 2025 年 1 月 21 日
I need to create pictures with a specific Gabor pattern, with different levels of contrast - from 0% to 100%.
I know there is a "Gabor" function in Matlab, but I did not find a way to define the Gabor's contrast.
I know there is also a PsychToolbox function that creates a Gabor texture on the screen (Screen('DrawTexture', windowPtr, gaborid...), but I do not need to present the Gabors on screen, I need to save bitmap pictures, and I do not know how to capture pictures presented on a running PsychToolbox screen (so a function\code that captures the screen and saves it would be appreciated as well).
Thank you! Genie
  1 件のコメント
Ralph Andrews
Ralph Andrews 2020 年 5 月 1 日
Hi there,
Any chance you managed this? I need the exact same thing!

サインインしてコメントする。

回答 (1 件)

Sreeram
Sreeram 2025 年 1 月 21 日
Hi Genie,
To create Gabor patterns with different contrast levels in MATLAB, you can use the "imadjust" function to modify the contrast of the generated image. Here is how this may be done:
g = gabor(20, 30);
gaborPattern = real(g.SpatialKernel);
% Example for 35% contrast
contrastLevel = 0.35;
adjustedPattern = imadjust(gaborPattern, [0, 1], [0.5 - contrastLevel/2, 0.5 + contrastLevel/2]);
imshow(adjustedPattern)
% Example for 100% contrast
contrastLevel = 1;
adjustedPattern = imadjust(gaborPattern, [0, 1], [0.5 - contrastLevel/2, 0.5 + contrastLevel/2]);
imshow(adjustedPattern)
The "imadjust" function adjusts the contrast by remapping the intensity values of an image. More information on the function is available in the following documentation:
The image may be saved using the "imwrite" function:
I hope this helps!

カテゴリ

Help Center および File ExchangeImage display and manipulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by