查找在Matlab使用BLOCKPROC最大像素 [英] Find maximum pixel using BLOCKPROC in Matlab

查看:407
本文介绍了查找在Matlab使用BLOCKPROC最大像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matlab的我有一个三维矩阵(超过100帧512×512)。我的目标是要找到在整个超矩阵一些重新presentative点。要做到这一点,我实现了传统的(而不是非常有效的)方法:我细分大型矩阵成更小的子矩阵,然后我期待与最高值的像素。后这样做,我改变非常像素的那些相对坐标中的子矩阵来参照的大型矩阵全局坐标。

In Matlab I've got a 3D matrix (over 100 frames 512x512). My goal is to find some representative points through the whole hyper-matrix. To do so I've implemented the traditional (and not very efficient) method: I subdivide the large matrix into smaller sub-matrices and then I look for the pixel with the highest value. After doing that I change those relative coordinates of that very pixel in the sub-matrix to global coordinates referenced to the large matrix.

现在,我重新设计的算法。我(这实际上是我在做什么与我的老算法)在 BLOCKPROC 的功能是非常有效的看出,为了分析大量的矩阵块逐块。我读过的文件,但我不知道怎么了好玩的功能应实行提取的每个块的最高值像素。谢谢你在前进。

Now, I'm redesigning the algorithm. I've seen that in order to analyze a large matrix block-by-block (that's actually what I'm doing with my old algorithm) the BLOCKPROC function is very efficient. I've read the documentation but I don't know how the "fun" function should be implemented to extract that the pixel with the highest value of each block. Thank you in advance.

*我试图让参照全球矩阵的最大像素的坐标,我真的不关心自己的价值。

*I'm trying to get the coordinates of those maximum pixels referenced to the global matrix, I really don't care about their value.

推荐答案

首先定义一个函数来找到一个(子)矩阵的最大的位置:

First define a function to find the location of the maximum of a (sub)matrix:

function loc = max_location(M);
[~, ii] = max(M(:));
[r c] = ind2sub(size(M),ii);
loc = [r c];

然后使用

blockproc(im, blocksize, @(x) x.location+max_location(x.data)-1)

其中,即时通讯是图像(二维数组)和块大小是一个1x2的向量确定块大小。在 blockproc 数据字段是子矩阵(你传递给 max_location )和位置字段包含子矩阵的左上角(您添加到 max_location结果的坐标,减1)。

where im is your image (2D array) and blocksize is a 1x2 vector specifying block size. Within blockproc, the data field is the submatrix (which you pass to max_location), and the location field contains the coordinates of the top-left corner of the submatrix (which you add to the result of max_location, minus 1).

例如:

>> blocksize = [3 3];

>> im = [ 0.3724    0.0527    0.4177        0.6981    0.0326    0.4607
          0.1981    0.7379    0.9831        0.6665    0.5612    0.9816
          0.4897    0.2691    0.3015        0.1781    0.8819    0.1564

          0.3395    0.4228    0.7011        0.1280    0.6692    0.8555
          0.9516    0.5479    0.6663        0.9991    0.1904    0.6448
          0.9203    0.9427    0.5391        0.1711    0.3689    0.3763 ];

>> blockproc(im, blocksize, @(x) x.location+max_location(x.data)-1)

ans =
     2     3     2     6
     5     1     5     4

这意味着你的块最大值分别位于坐标(2,3),(5,1),(2,6)和(5,4)

meaning your block maxima are located at coordinates (2,3), (5,1), (2,6) and (5,4)

这篇关于查找在Matlab使用BLOCKPROC最大像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆