contrastmodulate.m
来自「显著区域检测。求的图像中感兴趣区域的位置」· M 代码 · 共 64 行
M
64 行
function resultImg = contrastModulate(img, modulationMap, varargin)% contrastModulate - contrast modulates an image according to a map%% resultImg = contrastModulate(img, modulationMap, baseContrast, baseColor)% contrast modulates image img such that that it has full% contrast where modulationMask is 1. % Img is an Image structure, modulationMap a map assumed % to be scaled between 0 and 1 and of the same size as img. % baseContrast (between 0 and 1) is the image contrast % where modulationMap = 0. % baseColor is the color at locations with low contrast.%% resultImg = contrastModulate(img, modulationMap, baseContrast)% assumes baseColor = [1 1 1] (white).%% resultImg = contrastModulate(img, modulationMap, baseContrast)% assumes baseContrast = 0 (opaque).%% See also plotSalientLocation, dataStructures.% This file is part of the SaliencyToolbox - Copyright (C) 2006-2007% by Dirk B. Walther and the California Institute of Technology.% See the enclosed LICENSE.TXT document for the license agreement. % More information about this project is available at: % http://www.saliencytoolbox.netif length(varargin) >= 1 baseCon = varargin{1};else baseCon = 0;endif length(varargin) >= 2 baseCol = varargin{2}; if numel(baseCol) == 1 baseCol = baseCol * [1 1 1]; endelse baseCol = [1 1 1];endimData = loadImage(img);if img.dims == 2 imData = repmat(imData,[1 1 3]);endm = modulationMap.data;if (size(m,1) ~= img.size(1) || size(m,2) ~= img.size(2)) fatal('Image and modulation map must have the same size!');endalpha = m * (1 - baseCon) + baseCon;beta = 1 - alpha;for c = 1:3 res(:,:,c) = alpha.*imData(:,:,c) + beta*baseCol(c);endif isnan(img.filename) label = 'contrast modulated image';else label = ['contrast modulated ' img.filename];endresultImg = initializeImage(res,label);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?