Not getting Poisson Noise in octave

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Not getting Poisson Noise in octave

sivahari
Hi all,

I am not getting imnoise(j,'poisson') in octave. My friends have it in Matlab. Is there any alternative for it in Octave?

--
with warm regards
Sivahari Nandakumar
Appropriate Technology Promotion Society
Eroor, Vyttila 09446582917
http://sivaharicec.blogspot.com
--------------------------------------------------------
      fighting for knowledge freedom

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

c.-2

On 2 Dec 2012, at 06:13, Sivahari Nandakumar wrote:

> Hi all,
>
> I am not getting imnoise(j,'poisson') in octave. My friends have it in Matlab. Is there any alternative for it in Octave?

according to what I see in matlabs imnoise docs you could try something like:

aa = imread ("someimage.jpg");
bb = uint8 (arrayfun (@poissrnd, aa));
subplot (1, 2, 1)
imshow (aa)
subplot (1, 2, 2)
imshow (bb)

beware, it may take some time ...

HTH,
c.


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

sivahari
Thank you c. it worked.

--Sivahari

2012/12/2 c. <[hidden email]>

On 2 Dec 2012, at 06:13, Sivahari Nandakumar wrote:

> Hi all,
>
> I am not getting imnoise(j,'poisson') in octave. My friends have it in Matlab. Is there any alternative for it in Octave?

according to what I see in matlabs imnoise docs you could try something like:

aa = imread ("someimage.jpg");
bb = uint8 (arrayfun (@poissrnd, aa));
subplot (1, 2, 1)
imshow (aa)
subplot (1, 2, 2)
imshow (bb)

beware, it may take some time ...

HTH,
c.





--
with warm regards
Sivahari Nandakumar
Appropriate Technology Promotion Society
Eroor, Vyttila 09446582917
http://sivaharicec.blogspot.com
--------------------------------------------------------
      fighting for knowledge freedom

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

Terry Duell
In reply to this post by c.-2
On Sun, 02 Dec 2012 18:53:41 +1100, c. <[hidden email]> wrote:

>
> On 2 Dec 2012, at 06:13, Sivahari Nandakumar wrote:
>
>> Hi all,
>>
>> I am not getting imnoise(j,'poisson') in octave. My friends have it in  
>> Matlab. Is there any alternative for it in Octave?
>
> according to what I see in matlabs imnoise docs you could try something  
> like:
>
> aa = imread ("someimage.jpg");
> bb = uint8 (arrayfun (@poissrnd, aa));
> subplot (1, 2, 1)
> imshow (aa)
> subplot (1, 2, 2)
> imshow (bb)
>
> beware, it may take some time ...

You could also try something like this...

bb = aa + 3/256*randn(h,w);
where h,w are the height, width of aa.

The first approach takes 13.74 sec here, for my little test image. The  
second takes about 0.01 sec.
The results appear quite similar, but I guess it depends on your  
particular need.

Cheers,
--
Regards,
Terry Duell
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

Carnë Draug
On 3 December 2012 00:05, Terry Duell <[hidden email]> wrote:

> On Sun, 02 Dec 2012 18:53:41 +1100, c. <[hidden email]> wrote:
>
>>
>> On 2 Dec 2012, at 06:13, Sivahari Nandakumar wrote:
>>
>>> Hi all,
>>>
>>> I am not getting imnoise(j,'poisson') in octave. My friends have it in
>>> Matlab. Is there any alternative for it in Octave?
>>
>>
>> according to what I see in matlabs imnoise docs you could try something
>> like:
>>
>> aa = imread ("someimage.jpg");
>> bb = uint8 (arrayfun (@poissrnd, aa));
>> subplot (1, 2, 1)
>> imshow (aa)
>> subplot (1, 2, 2)
>> imshow (bb)
>>
>> beware, it may take some time ...
>
>
> You could also try something like this...
>
> bb = aa + 3/256*randn(h,w);
> where h,w are the height, width of aa.
>
> The first approach takes 13.74 sec here, for my little test image. The
> second takes about 0.01 sec.
> The results appear quite similar, but I guess it depends on your particular
> need.

Hey,

I'd be most thankful if you could submit a patch to add this to the
image package. The imnoise function already exists in the image
package, it's just missing this option. There's a switch block for the
type so should be very easy to implement it. Just send me a patch (or
better, post it on the
https://sourceforge.net/p/octave/feature-requests/ tracker) and I'll
make the commit.

Thanks,
Carnë
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

Terry Duell
Hello Carnë,


On Mon, 03 Dec 2012 10:14:55 +1100, Carnë Draug <[hidden email]>  
wrote:

[snip]

>> You could also try something like this...
>>
>> bb = aa + 3/256*randn(h,w);
>> where h,w are the height, width of aa.
>>
>> The first approach takes 13.74 sec here, for my little test image. The
>> second takes about 0.01 sec.
>> The results appear quite similar, but I guess it depends on your  
>> particular
>> need.
>
> Hey,
>
> I'd be most thankful if you could submit a patch to add this to the
> image package. The imnoise function already exists in the image
> package, it's just missing this option. There's a switch block for the
> type so should be very easy to implement it. Just send me a patch (or
> better, post it on the
> https://sourceforge.net/p/octave/feature-requests/ tracker) and I'll
> make the commit.

I don't think I have the foggiest idea of how one would go about doing  
that, meaning where the above would fit into the scheme of things in  
imnoise, and how to make a patch.
I would if I could...but I think it would take me too long to figure out  
what I had to do.
When I have some time and inclination, I will see if I can understand how  
the above code snippet should fit into imnoise, and how to make a patch.
One of the problems is that by the time I get around it, I'll probably  
have forgotten :-)

Cheers,
--
Regards,
Terry Duell
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

Carnë Draug
On 3 December 2012 01:02, Terry Duell <[hidden email]> wrote:
> I don't think I have the foggiest idea of how one would go about doing that,
> meaning where the above would fit into the scheme of things in imnoise, and
> how to make a patch.

The easiest method is to open the imnoise.m file, put the code in the
switch block and then upload the file to the bug tracker. Dead easy,
and it's all written in the own Octave language that we all already
know. Take a look at
https://sourceforge.net/p/octave/code/11403/tree/trunk/octave-forge/main/image/inst/imnoise.m
The switch block is on line 57, and there's a case for gaussian, salt
and pepper, and speckle. It's just a matter of adding one for poisson.

Carnë
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

Terry Duell
On Mon, 03 Dec 2012 11:17:48 +1100, Carnë Draug <[hidden email]>  
wrote:

> On 3 December 2012 01:02, Terry Duell <[hidden email]> wrote:
>> I don't think I have the foggiest idea of how one would go about doing  
>> that,
>> meaning where the above would fit into the scheme of things in imnoise,  
>> and
>> how to make a patch.
>
> The easiest method is to open the imnoise.m file, put the code in the
> switch block and then upload the file to the bug tracker. Dead easy,
> and it's all written in the own Octave language that we all already
> know. Take a look at
> https://sourceforge.net/p/octave/code/11403/tree/trunk/octave-forge/main/image/inst/imnoise.m
> The switch block is on line 57, and there's a case for gaussian, salt
> and pepper, and speckle. It's just a matter of adding one for poisson.

OK, that makes it a bit clearer.
I'll see how I go.


Cheers,
--
Regards,
Terry Duell
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

c.-2
In reply to this post by Terry Duell

On 3 Dec 2012, at 00:05, Terry Duell wrote:

> You could also try something like this...
>
> bb = aa + 3/256*randn(h,w);
> where h,w are the height, width of aa.
>
> The first approach takes 13.74 sec here, for my little test image. The second takes about 0.01 sec.
> The results appear quite similar, but I guess it depends on your particular need.

that is equivalent to

bb = imnoise (aa, 'gaussian', 0, sqrt(3/256))

which works the same in Matlab and Octave, the version I proposed
is equivalent to

bb = imnoise (aa, 'poisson')

which is not yet implemented in Octave:
http://octave.sourceforge.net/image/function/imnoise.html
http://www.mathworks.it/it/help/images/ref/imnoise.html

whether it is equivalent to use either of the two indeed depends on the OP's particular application.

> --
> Regards,
> Terry Duell


c.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

Terry Duell
Hello Carlo,

On Mon, 03 Dec 2012 14:56:00 +1100, c. <[hidden email]> wrote:

>
> On 3 Dec 2012, at 00:05, Terry Duell wrote:
>
>> You could also try something like this...
>>
>> bb = aa + 3/256*randn(h,w);
>> where h,w are the height, width of aa.
>>
>> The first approach takes 13.74 sec here, for my little test image. The  
>> second takes about 0.01 sec.
>> The results appear quite similar, but I guess it depends on your  
>> particular need.
>
> that is equivalent to
>
> bb = imnoise (aa, 'gaussian', 0, sqrt(3/256))
>
> which works the same in Matlab and Octave, the version I proposed
> is equivalent to
>
> bb = imnoise (aa, 'poisson')
>
> which is not yet implemented in Octave:

[snip]

OK, then I should not be making any changes to the imnoise code.

Cheers,
--
Regards,
Terry Duell
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

c.-2

On 3 Dec 2012, at 05:44, Terry Duell wrote:

> Hello Carlo,
>
> On Mon, 03 Dec 2012 14:56:00 +1100, c. <[hidden email]> wrote:
>
>>
>> On 3 Dec 2012, at 00:05, Terry Duell wrote:
>>
>>> You could also try something like this...
>>>
>>> bb = aa + 3/256*randn(h,w);
>>> where h,w are the height, width of aa.
>>>
>>> The first approach takes 13.74 sec here, for my little test image. The second takes about 0.01 sec.
>>> The results appear quite similar, but I guess it depends on your particular need.
>>
>> that is equivalent to
>>
>> bb = imnoise (aa, 'gaussian', 0, sqrt(3/256))
>>
>> which works the same in Matlab and Octave, the version I proposed
>> is equivalent to
>>
>> bb = imnoise (aa, 'poisson')
>>
>> which is not yet implemented in Octave:
>
> [snip]
>
> OK, then I should not be making any changes to the imnoise code.
>
> Cheers,

On the other hand I see now that poissrnd does accept a matrix as input, so:

poissrnd (aa)

works fine and is much faster than my previous version
I'll have a look at changing "imnoise" accordingly.

c.


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

Terry Duell
On Mon, 03 Dec 2012 18:20:55 +1100, c. <[hidden email]> wrote:

[snip]

>
> On the other hand I see now that poissrnd does accept a matrix as input,  
> so:
>
> poissrnd (aa)
>
> works fine and is much faster than my previous version
> I'll have a look at changing "imnoise" accordingly.

Bonza.

Cheers,
--
Regards,
Terry Duell
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

c.-2

On 3 Dec 2012, at 09:53, Terry Duell wrote:

> On Mon, 03 Dec 2012 18:20:55 +1100, c. <[hidden email]> wrote:
>
> [snip]
>
>>
>> On the other hand I see now that poissrnd does accept a matrix as input, so:
>>
>> poissrnd (aa)
>>
>> works fine and is much faster than my previous version
>> I'll have a look at changing "imnoise" accordingly.
>
> Bonza.
>
> Cheers,
> --

I just pushed the implementation of

imnoise (A, 'poisson')

to the SVN repo, and added a few tests and demos.
c.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Not getting Poisson Noise in octave

Carnë Draug-2
On 3 December 2012 19:08, c. <[hidden email]> wrote:

>
> On 3 Dec 2012, at 09:53, Terry Duell wrote:
>
>> On Mon, 03 Dec 2012 18:20:55 +1100, c. <[hidden email]> wrote:
>>
>> [snip]
>>
>>>
>>> On the other hand I see now that poissrnd does accept a matrix as input, so:
>>>
>>> poissrnd (aa)
>>>
>>> works fine and is much faster than my previous version
>>> I'll have a look at changing "imnoise" accordingly.
>>
>> Bonza.
>>
>> Cheers,
>> --
>
> I just pushed the implementation of
>
> imnoise (A, 'poisson')
>
> to the SVN repo, and added a few tests and demos.
> c.

Awesome. Thanks a lot. I have fixed the NEWS file to mention this too.

Carnë
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave