Re: Resizing Graphics
- To: mathgroup at smc.vnet.net
- Subject: [mg36322] Re: Resizing Graphics
- From: "Mariusz Jankowski" <mjkcc at usm.maine.edu>
- Date: Sat, 31 Aug 2002 01:26:09 -0400 (EDT)
- References: <akn0lk$llm$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Aaron" <au198295 at hotmail.com> wrote in message news:akn0lk$llm$1 at smc.vnet.net... > I was wondering if there is a method for resizing Raster graphics > (resizing the actual matrix of pixels, not just the display size). I > am processing a large number of JPEG images, and we sometimes need to > reduce the image size to allow data processing algorithms to function > without running out of memory. In the past we simply used a program > such as Photoshop to resize them before importing them into > Mathematica. Due to the number of images we are processing now this > is very inconvenient and it would be very useful if there was a method > for accomplishing it in Mathematica, but I can't find one. I also > thought about doing something simple like sampling every few pixels or > averaging, but I thought there might be a method with more efficacy > than this. I also tried exporting the graphics with the Export command > as new JPEGs and manipulating the ImageResolution and ImageSize > options but this seemed to have no effect. Any help would be much > appreciated. > Thanks, > Aaron Urbas > Aaron, with the Digital Image Processing package see Downsample, Decimate or Resize. Else, the simplest method is to take every k'th sample, which can be done with the Take command. This imports the image and returns the raw data. img = Import["somefile.jpg"][[1,1]]; For an image with dimensions nr x nc, and if you want to take every other sample use: small = Take[img, {1, nr, 2}, {1, nc, 2}]; You can also perform smoothing using ListConvolve prior to downsampling to eliminate some of the visual artifacts of downsampling. Done. -- =============================== Mariusz Jankowski University of Southern Maine mjkcc at usm.maine.edu 207-780-5580