概述
老派for-Loop方法 –
%%// Outputs that you are interested in are - img, x1 and y1
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
for k1= 1:size(img,1)-15
for k2= 1:size(img,2)-15
img1 = img(k1:k1+15,k2:k2+15);
[val,ind1] = max(img1(:));
img(k1+8,k2+8)=val; %%// Store the max grey value into the image
[x1(k1,k2),y1(k1,k2)] = ind2sub([16 16],ind1);
end
end
编辑1:要计算此滑动窗口的平均值,请使用此 –
window_size = 16; %%// Edit this to your window size
wsz = window_size-1;
mp = round(window_size/2);
%%// Outputs that you are interested in are - img, x1 and y1
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(:)));
img1(k1+mp,k2+mp)=val; %%// Store the mean grey value into the image
end
end
figure,imshow(img1)
编辑2:
img1 = Z;
for k1= 1:size(Z,1)-wsz
for k2= 1:size(Z,2)-wsz
window_data = Z(k1:k1+wsz,k2:k2+wsz);
val = mean(window_data(:))
if (val~=0)
keyboard;
error('Look, there is a non-zero mean value!');
end
% img1(k1+mp,k2+mp)=val; %%// Store the mean grey value into the image
display(val);
end
end
最后
以上就是简单爆米花为你收集整理的matlab创建多个窗口,Matlab在图像上创建窗口的全部内容,希望文章能够帮你解决matlab创建多个窗口,Matlab在图像上创建窗口所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复