【发布时间】:2015-10-07 06:32:48
【问题描述】:
我想在我的隐写算法中使用 canny 边缘检测,所以当我需要例如 250 像素来隐藏信息时,我必须找到 canny 的最佳低/高阈值,以便在图像中找到至少 250 个最清晰的像素。
另一个例子,当我需要 500 像素来隐藏信息时,我必须找到低/高阈值才能在图像中找到至少 500 像素。
我认为我可以使用二分搜索,但它没有返回最佳阈值。这是我的二分搜索功能:
function [ th ] = getThreshold( I, N, w )
% limit is set to 1% of the message
% length
% no. of edge pixels,ne ? N + 0.01 × N
% and ne ? N
% ne = number of edge pixels in I, when
% Canny edge detector is used on I with
% high threshold th and low threshold
% tl = 0.4 ? th and width w
limit = (0.01 * N);
tmax = 0.8;
tmin = 0;
set = true;
while(set)
th = double((tmax + tmin)/2);
BW = edge(I,'canny',[tmin tmax],'both',w);
% it returns the number of pixels in the edges obtained through Canny
% edge detector
ne = getEdgePixelCount(BW);
diff = ne - N;
if diff > limit
tmin = th;
elseif diff < 0
tmax = th;
else
set = false;
end
end
【问题讨论】:
-
计算sobel震级怎么样,保持N最高?