Info

此问题已关闭。 请重新打开它进行编辑或回答。

how this [1 2] working and giving me the difference ?

1 次查看(过去 30 天)
My code is working well, everything is expected as it should be but i want to go deep and want to learn more how this code is giving me the difference ?
Is [1 2] divide it into blocks ? If yes then how ?
O_IMAGE = imread('boat_256x256.tif');
% The difference
THE_DIFF = blkproc(double(O_IMAGE), [1 2], inline('x(1) - x(2)'));
Anyone who can elaborate it to me ? Thanks in Advance

回答(1 个)

Walter Roberson
Walter Roberson 2020-8-15
blkproc is considered obsolete and should not be used.
[1 2] means that the function will start in the top left corner and take a 1 pixel by 2 pixel part of the image, and will pass that to the function and will store the result. Then it will move right by 2 pixels and take 1x2 pixels there, pass that to the function, and it will keep sliding the window over two pixels at a time. When it gets to the end of the first row it will start at the beginning of the second row, take 1x2 there, pass it to the function and so on.
The way it does all of this is by using for loops internally. The code did not separate the image into separate variables and process each variable, and did not create cell arrays of subsets and process each subset: it just used for loops.

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by