Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

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

1 view (last 30 days)
Rizwan Taj
Rizwan Taj on 15 Aug 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
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

Answers (1)

Walter Roberson
Walter Roberson on 15 Aug 2020
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.

This question is closed.

Community Treasure Hunt

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

Start Hunting!