Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9560

Re: Image Processing Pixel Values Export Question

From David Bailey <dave@removedbailey.co.uk>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Image Processing Pixel Values Export Question
Date 2012-04-11 22:16 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jm4vs1$2je$1@smc.vnet.net> (permalink)
References <jm0jt9$adb$1@smc.vnet.net>

Show all headers | View raw


On 10/04/2012 07:27, Physica wrote:
> Hello,
>
> I am trying to store a bunch of values (pixels) into a file everything
> seems ok until I try to push the value to XLS file the XLS file just
> stores the variable name instead of the values. Can someone help me
> with pushing the right values
>
> Codes loads a movie (H264) records the pixels of one channel and
> stores the values per frame, then it supposed to store the values into
> xls file
>
>
> ----------------------------------------------------
>
> (* Import Video *)
> VideoL = Import[
>     "D:\\experiment\\XYZ.mov", {{"BitDepth", "ColorSpace",
>       "Duration", "FrameCount", "FrameRate", "ImageSize",
>       "VideoEncoding"}}];
>
> FrameCount = VideoL[[4]];
> (* Enter how many frames you wish to load *)
> nFrames = Array[0 + #&, 3];
> lFrames = Length[nFrames]
> (* Reload Image*)
> h = Import[
>     "D:\\experiment\\XYZ.mov", {"QuickTime", "Frames", nFrames}];
> (* jCount = 1;
> iCount = 1;
> PixelValues = ImageData[h[[jCount]]][[170, 101]][[iCount]]; *)
> Table[PV[i], {i, 1, lFrames, 1}];
>
> For[i = 1, i<= lFrames, i++,
>   PV[i] = ImageData[h[[i]]][[170, 101]][[1]]]
>
> Export["mfile.xls", PV, "XLS"]
>
>
>
>
Your code defines a function PV, rather than an array (there may be 
other problems as well, I have not tested it). Try:

PV=Table[ImageData[h[[i]]][[170, 101]][[1]]],{i,1,lFrames}]

Note that PV[i]=... defines a function.
PV[[i]]=... sets an element of an array stored in PV (but PV must 
already be initialised with an array - e.g. using ConstantArray.

Finally, it seems rather strange to store pixel values in an XL file - 
is there a reason for doing this, rather than writing them to a text 
file (or even a binary file, for maximum speed). Exporting to XL will 
certainly be slower, and if you are processing video, performance is 
likely to be important!

David Bailey
http://www.dbaileyconsultancy.co.uk

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Image Processing Pixel Values Export Question Physica <oren.sternberg@gmail.com> - 2012-04-10 06:27 +0000
  Re: Image Processing Pixel Values Export Question David Bailey <dave@removedbailey.co.uk> - 2012-04-11 22:16 +0000

csiph-web