I need to find the product of every all the pixel values in a matrix. That is, if an image of size 256×256×3 is taken... i need to find the entire product of 65536 values

4 Kommentare

Matt J
Matt J am 11 Apr. 2018
There are 196608 values in a 256×256×3 image.
Matt J
Matt J am 11 Apr. 2018
Bearbeitet: Matt J am 11 Apr. 2018
You have many open threads, i.e., answers to your questions that you have not accepted. You are more likely to get responses if you Accept-click the answers that helped you.
Sneha P S
Sneha P S am 11 Apr. 2018
Ok
Sneha P S
Sneha P S am 11 Apr. 2018
Sorry i just meant to mention the matrix of size 256×256. Will anyone help me to do the same

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Rik
Rik am 11 Apr. 2018

1 Stimme

You can use prod.
A=rand(256,256);
total_product=prod(A(:));
But it is very likely that the product will be either 0, inf or -inf, because of the large number of elements.

1 Kommentar

Matt J
Matt J am 12 Apr. 2018
But it is very likely that the product will be either 0, inf or -inf, because of the large number of elements.
@Sneha, Is the ulterior motive to compute the log-product? If so, better to do this by summation.
logproduct=sum(log(A(:)));

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Read, Write, and Modify Image finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 11 Apr. 2018

Kommentiert:

am 12 Apr. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by