-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetRBDPriorMap.m
More file actions
58 lines (48 loc) · 1.95 KB
/
getRBDPriorMap.m
File metadata and controls
58 lines (48 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function RBDprior = getRBDPriorMap(srcImg)
addpath(genpath('RBD\'));
addpath(genpath('RBD\Funs\'));
% srcImg = double(uint8Img)./255;
% [ww,hh,nchns] = size(srcImg);
% if nchns == 1
% srcImg(:, :, 2) = srcImg(:, :, 1);
% srcImg(:, :, 3) = srcImg(:, :, 1);
% end
%% RBD prior (RBD)========================================
doFrameRemoving = true;
useSP = true;
if size(srcImg,3) == 1
srcImg(:, :, 2) = srcImg(:, :, 1);
srcImg(:, :, 3) = srcImg(:, :, 1);
end
if doFrameRemoving
[noFrameImg, frameRecord] = removeframeRBD(srcImg, 'sobel');
[h, w, ~] = size(noFrameImg);
else
noFrameImg = srcImg;
[h, w, chn] = size(noFrameImg);
frameRecord = [h, w, 1, h, 1, w];
end
% Segment input rgb image into patches (SP/Grid)
pixNumInSP = 600; %pixels in each superpixel
spnumber = round( h * w / pixNumInSP ); %super-pixel number for current image
if useSP
[idxImg, adjcMatrix, pixelList] = SLIC_Split(noFrameImg, spnumber);
else
[idxImg, adjcMatrix, pixelList] = Grid_Split(noFrameImg, spnumber);
end
%% Get super-pixel properties
spNum = size(adjcMatrix, 1);
meanRgbCol = GetMeanColor(noFrameImg, pixelList);
meanLabCol = colorspace('Lab<-', double(meanRgbCol)/255);
meanPos = GetNormedMeanPos(pixelList, h, w);
bdIds = GetBndPatchIds(idxImg);
colDistM = GetDistanceMatrix(meanLabCol);
posDistM = GetDistanceMatrix(meanPos);
[clipVal, geoSigma, neiSigma] = EstimateDynamicParas(adjcMatrix, colDistM);
%% Saliency Optimization
[bgProb, bdCon, bgWeight, fgProb] = EstimateBgProb(colDistM, adjcMatrix, bdIds, clipVal, geoSigma);
smapName = 'unused';
RBDprior = SaveSaliencyMapPP(fgProb, pixelList, frameRecord, smapName, true);
% figure
% imshow(RBDprior)
% title('RBDprior map')