-3

To get the pixel values (intensity) from an image I tried

data = PixelValue[image, {1;;1024, 1;;371}, "Byte"]
data = [[All, 1]]

I expected to get a matrix, but I get intensity information, but there is no matrix, but just a lot lists.

What should I do? My final aim is Gaussian fitting with particles image.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
H. Bae
  • 5
  • 1
  • 1
    In Mathematica a matrix is represented by a list of lists. – m_goldberg Jul 14 '17 at 09:02
  • Would MatrixForm help? – Ruud3.1415 Jul 14 '17 at 09:33
  • Note that images usually are sRGB-encoded. You may want to convert your image to Linear RGB before fitting. – Alexey Popkov Jul 16 '17 at 07:04
  • 2
    @AlexeyPopkov: Note that this is only true for consumer cameras. Industrial cameras usually measure brightness linearly. (At least the ones I've worked with) – Niki Estner Jul 16 '17 at 07:51
  • @nike Thanks. As I understand, industrial cameras probably never save images as JPG (at least by default). Which image format(s) do they prefer? – Alexey Popkov Jul 16 '17 at 07:54
  • 1
    @AlexeyPopkov: I am working e.g. with expensive Photron CMOS cameras, they export as png. – mrz Jul 27 '17 at 02:39
  • 2
    @AlexeyPopkov: The industrial cameras I work with don't save images at all. You're expected to get the images via GigE interface, and save them yourself, usually as png, tiff (for 16bit color depth) or bmp format. – Niki Estner Aug 01 '17 at 09:38
  • You may be interested in this answer: https://mathematica.stackexchange.com/questions/27642/fitting-a-two-dimensional-gaussian-to-a-set-of-2d-pixels – Mammouth Apr 05 '18 at 13:34

1 Answers1

0

To get a list of lists of pixel values of that part of the image, you'd use the following. It's going to give results in the range [0,1].

ImageData@ImageTake[image,{1,1024},{1,371}]

You could use //MatrixForm at the end of that to get a giant matrix, but beware, it could be a little intensive to display a matrix that big. Like, crash-your-kernel intensive!

I'm not entirely sure what you mean by "Gaussian fitting with particles image", maybe you could clarify. But if you meant trying to find some linear transform that will make the image's histogram look vaguely gaussian, you could use this, where mu is the mean of your gaussian and sigma is the standard deviation.

i = ImageTake[image,{1,1024},{1,371}];
HistogramTransform[image,NormalDistribution[mu, sigma]]

Good luck!

laudiacay
  • 562
  • 4
  • 14