The old version of block processing in Matlab is invoked by "blkproc",
while the new version which I used now (R2009b) introduces a new
method as "blockproc". The difference according to the official
website I can see is the new function consider each block as a struct,
rather than matrix in the old version.
As I assumed, the newer one should more effective and faster than the
old one. However, it's not true. Why does this happen? The test code
is as following, the old function is about 10 times faster than the
newer one???:
>> a = rgb2gray(imread('test.jpg'));
>> y1 = @(x) mean2(x)*ones(size(x));
>> y2 = @(x) mean2(x.data)*ones(size(x.data));
>> tic;e = blkproc(a,[2 2],y1);toc;tic;f = blockproc(a,[2 2],y2);toc;
Warning: BLKPROC will be removed in a future release. Use BLOCKPROC
instead.
> In blkproc at 68
Elapsed time is 0.431351 seconds.
Elapsed time is 4.582460 seconds.
|
|
0
|
|
|
|
Reply
|
xenoszh (14)
|
5/21/2010 8:57:11 PM |
|
On May 21, 9:57=A0pm, Parker <xeno...@gmail.com> wrote:
> The old version of block processing in Matlab is invoked by "blkproc",
> while the new version which I used now (R2009b) introduces a new
> method as "blockproc". The difference according to the official
> website I can see is the new function consider each block as a struct,
> rather than matrix in the old version.
>
> As I assumed, the newer one should more effective and faster than the
> old one. However, it's not true. Why does this happen? The test code
> is as following, the old function is about 10 times faster than the
> newer one???:
>
> >> a =3D rgb2gray(imread('test.jpg'));
> >> y1 =3D @(x) mean2(x)*ones(size(x));
> >> y2 =3D @(x) mean2(x.data)*ones(size(x.data));
> >> tic;e =3D blkproc(a,[2 2],y1);toc;tic;f =3D blockproc(a,[2 2],y2);toc;
>
> Warning: BLKPROC will be removed in a future release. Use BLOCKPROC
> instead.> In blkproc at 68
>
> Elapsed time is 0.431351 seconds.
> Elapsed time is 4.582460 seconds.
no comments?
|
|
0
|
|
|
|
Reply
|
Parker
|
5/22/2010 8:51:52 AM
|
|
Parker <xenoszh@gmail.com> wrote in message <d7dbddd0-5571-4ec4-8183-e5f76a31edb8@f14g2000vbn.googlegroups.com>...
> On May 21, 9:57 pm, Parker <xeno...@gmail.com> wrote:
> > The old version of block processing in Matlab is invoked by "blkproc",
> > while the new version which I used now (R2009b) introduces a new
> > method as "blockproc". The difference according to the official
> > website I can see is the new function consider each block as a struct,
> > rather than matrix in the old version.
> >
> > As I assumed, the newer one should more effective and faster than the
> > old one. However, it's not true. Why does this happen? The test code
> > is as following, the old function is about 10 times faster than the
> > newer one???:
> >
> > >> a = rgb2gray(imread('test.jpg'));
> > >> y1 = @(x) mean2(x)*ones(size(x));
> > >> y2 = @(x) mean2(x.data)*ones(size(x.data));
> > >> tic;e = blkproc(a,[2 2],y1);toc;tic;f = blockproc(a,[2 2],y2);toc;
> >
> > Warning: BLKPROC will be removed in a future release. Use BLOCKPROC
> > instead.> In blkproc at 68
> >
> > Elapsed time is 0.431351 seconds.
> > Elapsed time is 4.582460 seconds.
>
> no comments?
Why do you assume the new version is faster?
Does Matlab handles structures faster than Matrices? I'm not sure.
Though the performance gap you found is beyond reasonable.
|
|
0
|
|
|
|
Reply
|
Royi
|
5/22/2010 9:15:09 AM
|
|
"Royi Avital" <RoyiREMOVEAvital@yahoo.com> wrote in message <ht87at$u9$1@fred.mathworks.com>...
> Parker <xenoszh@gmail.com> wrote in message <d7dbddd0-5571-4ec4-8183-e5f76a31edb8@f14g2000vbn.googlegroups.com>...
> > On May 21, 9:57 pm, Parker <xeno...@gmail.com> wrote:
> > > The old version of block processing in Matlab is invoked by "blkproc",
> > > while the new version which I used now (R2009b) introduces a new
> > > method as "blockproc". The difference according to the official
> > > website I can see is the new function consider each block as a struct,
> > > rather than matrix in the old version.
> > >
> > > As I assumed, the newer one should more effective and faster than the
> > > old one. However, it's not true. Why does this happen? The test code
> > > is as following, the old function is about 10 times faster than the
> > > newer one???:
> > >
> > > >> a = rgb2gray(imread('test.jpg'));
> > > >> y1 = @(x) mean2(x)*ones(size(x));
> > > >> y2 = @(x) mean2(x.data)*ones(size(x.data));
> > > >> tic;e = blkproc(a,[2 2],y1);toc;tic;f = blockproc(a,[2 2],y2);toc;
> > >
> > > Warning: BLKPROC will be removed in a future release. Use BLOCKPROC
> > > instead.> In blkproc at 68
> > >
> > > Elapsed time is 0.431351 seconds.
> > > Elapsed time is 4.582460 seconds.
> >
> > no comments?
>
> Why do you assume the new version is faster?
> Does Matlab handles structures faster than Matrices? I'm not sure.
>
> Though the performance gap you found is beyond reasonable.
The poor performance of BLOCKPROC in R2009b & R2010a for in-memory syntaxes is a known issue. In the latest release, R2010a, the BLKPROC warning has been removed (the warning suggesting to use BLOCKPROC instead).
BLOCKPROC provides additional functionality beyond BLKPROC, such as file-to-file block processing for arbitrarily large TIFF images. Unfortunately, for these in-memory syntaxes that BLKPROC supports, the performance of BLOCKPROC is not comparable to that of BLKPROC in the R2009b & R2010a releases.
Improving the in-memory syntax performance of BLOCKPROC such that it is comparable to BLKPROC is a very high priority.
|
|
0
|
|
|
|
Reply
|
Brendan
|
6/24/2010 5:30:33 PM
|
|
"Brendan Hannigan" <bhannigaHELLO@THEREmathworks.com> wrote in message <i004np$q1i$1@fred.mathworks.com>...
> "Royi Avital" <RoyiREMOVEAvital@yahoo.com> wrote in message <ht87at$u9$1@fred.mathworks.com>...
> > Parker <xenoszh@gmail.com> wrote in message <d7dbddd0-5571-4ec4-8183-e5f76a31edb8@f14g2000vbn.googlegroups.com>...
> > > On May 21, 9:57 pm, Parker <xeno...@gmail.com> wrote:
> > > > The old version of block processing in Matlab is invoked by "blkproc",
> > > > while the new version which I used now (R2009b) introduces a new
> > > > method as "blockproc". The difference according to the official
> > > > website I can see is the new function consider each block as a struct,
> > > > rather than matrix in the old version.
> > > >
> > > > As I assumed, the newer one should more effective and faster than the
> > > > old one. However, it's not true. Why does this happen? The test code
> > > > is as following, the old function is about 10 times faster than the
> > > > newer one???:
> > > >
> > > > >> a = rgb2gray(imread('test.jpg'));
> > > > >> y1 = @(x) mean2(x)*ones(size(x));
> > > > >> y2 = @(x) mean2(x.data)*ones(size(x.data));
> > > > >> tic;e = blkproc(a,[2 2],y1);toc;tic;f = blockproc(a,[2 2],y2);toc;
> > > >
> > > > Warning: BLKPROC will be removed in a future release. Use BLOCKPROC
> > > > instead.> In blkproc at 68
> > > >
> > > > Elapsed time is 0.431351 seconds.
> > > > Elapsed time is 4.582460 seconds.
> > >
> > > no comments?
> >
> > Why do you assume the new version is faster?
> > Does Matlab handles structures faster than Matrices? I'm not sure.
> >
> > Though the performance gap you found is beyond reasonable.
>
> The poor performance of BLOCKPROC in R2009b & R2010a for in-memory syntaxes is a known issue. In the latest release, R2010a, the BLKPROC warning has been removed (the warning suggesting to use BLOCKPROC instead).
>
> BLOCKPROC provides additional functionality beyond BLKPROC, such as file-to-file block processing for arbitrarily large TIFF images. Unfortunately, for these in-memory syntaxes that BLKPROC supports, the performance of BLOCKPROC is not comparable to that of BLKPROC in the R2009b & R2010a releases.
>
> Improving the in-memory syntax performance of BLOCKPROC such that it is comparable to BLKPROC is a very high priority.
As of today, the R2010b version of MATLAB is available and with it, Image Processing Toolbox 7.1.
In this latest release, we have greatly improved the performance of BLOCKPROC for the in-memory syntaxes (like those discussed in this thread). For most problems, BLOCKPROC performance should now be comparable to that of BLKPROC.
To set expectations, BLOCKPROC is a much more complex function than BLKPROC and that complexity comes with some overhead. When block processing an image, if the block size is very small, this overhead can represent a large amount of work relative to the actual processing of the image data. In these cases, BLOCKPROC's performance will suffer relative to BLKPROC (but in R2010b, it will still perform much better than in previous releases).
In general, unless your task requires a specific size block, you should choose blocks to be large to achieve the best performance (with either function).
On a semi-related side note, in R2010b BLOCKPROC also:
* supports reading/writing JPEG2000 files
* allows control over the padding behavior at image edges
I encourage folks who have found BLOCKPROC to be slow to have a look at R2010b.
-brendan
|
|
0
|
|
|
|
Reply
|
Brendan
|
9/3/2010 5:23:07 PM
|
|
|
4 Replies
153 Views
(page loaded in 0.116 seconds)
|