简体   繁体   English

带blockproc的两个输出

[英]Two outputs with blockproc


I have this function that calculates the value of the binary pattern of a 3*3 block which result form thresholding the 8 neighbers pixels with the center pixel and returns two outputs: the decimal value of the binary code, the same decimal value if it's uniform or 59 if not. 我有一个函数,该函数计算3 * 3块的二进制模式的值,该值导致形成以中心像素为阈值的8个相邻像素的阈值并返回两个输出:二进制代码的十进制值,如果相同,则相同的十进制值如果不是,则为59。

function [out1,out2] = lbpblock(im)
%... implementation details
out1 = decimal ;
out2 = uniform;
end

The problem is when trying to use blockproc like this 问题是尝试使用像这样的blockproc时

result = blockproc(im,[3 3],@lbpblock);

the result array is only two dimensions (eg. 85*85) and has only the first output. 结果数组只有二维(例如85 * 85),并且只有第一个输出。

when I tried 当我尝试

[res1 res2] = blockproc(im,[3 3],@lbpblock); 

I get "Error using ==> blockproc Too many output arguments". 我收到“使用==> blockproc时出错,输出参数过多”。
I tried to change the function signature 我试图更改功能签名

function out = lbpblock(im)
%... implementation details
out = [decimal, uniform];
end

the result array again two dimensions only but now (85*170) the first output is stored in odd columns and the second in even ones. 结果数组仍然仅是二维的,但现在(85 * 170),第一个输出存储在奇数列中,第二个输出存储在偶数列中。
Is there any trick to get blockproc to store the result in a 85*85*2 array?? 是否有任何技巧可以使blockproc将结果存储在85 * 85 * 2数组中?

You can achieve an NxNx2 array as output by concatenating in the third dimension. 通过在第三维中进行串联,可以实现NxNx2数组作为输出。

Example: 例:

im = magic(10);
r = blockproc(im, [3, 3], @func);

function r = func(im)
r1 = mean(im.data(:));
r2 = std(im.data(:));
r = cat(3, r1, r2);
end

The important line is cat(3, output1, output2) . 重要的行是cat(3, output1, output2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM