2017-04-26 54 views
0

我想实现滑动窗口算法。 目标是显示我所有的窗口。 但我只有1个窗口。 这里是我的代码:在Matlab中实现Sliding Window Algo

clc;clear all;` 
image = imread('tabTes.png'); 
imageWidth = size(image, 2); 
imageHeight = size(image, 1); 
windowWidth = 100; 
windowHeight = 100; 
for j = 1:imageHeight - imageHeight + 1 
    for i = 1:imageWidth - imageWidth + 1 
     SlideWindow = image(j:j + windowHeight - 1, i:i + windowWidth - 1, :); 
    end 
end 
figure 
imshow(SlideWindow); 

回答

0

试试这个:

clc;clear all;` 
image = imread('tabTes.png'); 
imageWidth = size(image, 2); 
imageHeight = size(image, 1); 
windowWidth = 100; 
windowHeight = 100; 
for j = 1:imageHeight - windowHeight + 1 
    for i = 1:imageWidth - windowWidth + 1 
     SlideWindow = image(j:j + windowHeight - 1, i:i + windowWidth - 1, :); 
     figure 
     imshow(SlideWindow); 
    end 
end 

要小心,虽然。这会产生很多数字。

+0

嗨,谢谢你的回复。但是它的输出和我的一样:( –

+0

抱歉没有捕获到你的索引变量,请在一分钟内查看我的编辑信息 – souty

+0

谢谢bro它的工作原理 还有另一个问题,我想解决的问题 接下来的几个小时我会在这里发帖 很高兴如果你想帮助我(再次):D –