Re: Image Processing Pixel Values Export Question
- To: mathgroup at smc.vnet.net
- Subject: [mg125975] Re: Image Processing Pixel Values Export Question
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Wed, 11 Apr 2012 18:15:38 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jm0jt9$adb$1@smc.vnet.net>
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