【发布时间】:2014-04-19 02:18:00
【问题描述】:
我需要在 matlab 的 32x32 窗口中分割图像。
然后我需要获取该窗口内图像的平均强度值并显示它。我不需要对图像应用均值滤波器。
这是我的算法:
Split image into window sizes of 32x32
if mean intensity of pixels in 32x32window > 200
split 32x32 window into 8x8 windows.
end
这是我尝试过的:
kernel = ones(32)/32^2; % Create averaging window.
output = conv2(grayImage, kernel, 'same'); % Get means
mean=mean(mean(output);
display (mean)
但是,这只是对我的图像应用过滤器。也试过这个:
window_size = 16;
wsz = window_size-1;
mp = round(window_size/2);
img = rgb2gray(input_image); %%// Gray level values
x1 = zeros(size(img)); %%// Row values for the maximum pixel in the 16x16 window
y1 = zeros(size(img)); %%// Column values for the maximum pixel in the 16x16 window
img1 = img;
for k1= 1:size(img,1)-wsz
for k2= 1:size(img,2)-wsz
window_data = img(k1:k1+wsz,k2:k2+wsz);
val = round(mean(window_data(:)));
display(val);
end
end
但此代码返回 0 表示每个窗口的平均强度。
任何人都可以建议一种方法吗?
【问题讨论】: