Borrar filtros
Borrar filtros

Blockproc error when including BorderSize argument

1 visualización (últimos 30 días)
and i ran the following code:
I = imread('cameraman.tif');
I = im2double(I);
imshow(I)
T = dctmtx(8);
dct = @(block_struct) T * block_struct.data * T';
B = blockproc(I,[8 8],dct,'BorderSize',[4 4],'Trim',false) %modification made here
The code was from the link above, but i included the 'BorderSize' criteria to allow for overlapping of the blocks. Upon running the code, i get the error saying:
Error using blockprocFunDispatcher
BLOCKPROC encountered an error while evaluating the user-supplied function handle,FUN.
Error in blockprocInMemory
[u1_output fun_nargout] = blockprocFunDispatcher(fun,block_struct,...
Error in blockproc
result_image = blockprocInMemory(source,fun,options);
What could be the issue causing the error message above? If i remove 'BorderSize',[4 4], 'Trim',false it works as normal like in the link but am i using it wrongly?
  2 comentarios
Adam
Adam el 8 de Ag. de 2019
Editada: Adam el 8 de Ag. de 2019
T is hard-coded to be of size 8 by 8.
You have now added a [4 4] border to your 8 by 8 blocks so they cannot multiply by T any more because they are not the same size.
Stewart Tan
Stewart Tan el 8 de Ag. de 2019
So is it not possible to apply dct with included borders? Do you have any suggestion on this?

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Ag. de 2019
I = imread('cameraman.tif');
I = im2double(I);
T = dctmtx(8);
dct = @(block_struct) T * block_struct.data * T';
B = blockproc(I,[4 4],dct,'BorderSize',[2 2],'Trim',false, 'padpartial', true); %modification made here
size(I)
size(B)
Note that B comes out larger than I because you have trim set to false.
Notice the pad partial being needed: without it then when you reach the edge of the image, you run off the edge. blockproc() keeps moving the window until the last of the [4 4] windows is at the right (or bottom) edge, leaving the specified border padding "hanging over" the end of the image.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by