[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #48943] Processing image freezes OS
From: |
Dan Sebald |
Subject: |
[Octave-bug-tracker] [bug #48943] Processing image freezes OS |
Date: |
Thu, 1 Sep 2016 06:00:55 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0 |
Follow-up Comment #5, bug #48943 (project octave):
Give the attached variation on your script file a try. As a comparison, I'll
first reduce the image size:
octave:43> myimg = uint8(2^8*rand(160,256,3));
octave:44> figure; tic; C = histro(myimg); toc
Elapsed time is 4.88092 seconds.
octave:45> figure; tic; C2 = histro2(myimg); toc
Elapsed time is 0.0739899 seconds.
So that is a factor of fifty times faster? I note that the two histograms do
not match in the last places:
octave:46> [C(end-7:end); C2(end-7:end)]
ans =
506 448 473 478 510 486 1207 0
506 448 473 478 510 486 477 730
and the reason is because in your formula:
C(img(i,j)+1) = C(img(i,j)+1)+1;
img(i,j) is an uint8 and the largest value an uint8 can be is 255. img(i,j)+1
is also an uint8, hence
img(i,j)=254 results in img(i,j)+1=255
img(i,j)=255 results in img(i,j)+1=255
i.e.,
octave:48> uint8(255)+1
ans = 255
So, let me run the larger image in just the new histro2.m script:
octave:49> myimg = uint8(2^8*rand(1600,2560,3));
octave:50> figure; tic; C2 = histro2(myimg); toc
Elapsed time is 2.20311 seconds.
2.2 seconds. That's pretty fast.
I'll also note that if you are passing in an image that has three planes, I
don't see how that comes out to be a "Gray Image" histogram. Both of these
histogram scripts include every element of every plane.
(file #38399)
_______________________________________________________
Additional Item Attachment:
File name: histro2.m Size:0 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?48943>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/