1 / 11

Image Processing in MapReduce

Image Processing in MapReduce. The Problem. Image processing involves the application of some operation on an Image Images are typically represented as a 2D-Matrix of values (Binary, Grayscale or RGB/CYMK color values) Operations on images are typically matrix operations.

ulric
Download Presentation

Image Processing in MapReduce

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Image Processing in MapReduce

  2. The Problem • Image processing involves the application of some operation on an Image • Images are typically represented as a 2D-Matrix of values (Binary, Grayscale or RGB/CYMK color values) • Operations on images are typically matrix operations. • Image Processing can be a computationally intensive process Original Image Processed Image

  3. Example: Sobel Edge Detection

  4. How to speed up Image Processing? • Parallelize operations within an image. • Parallelize operations across multiple images.

  5. Naïve MapReduce Implementation Map Task Map Task Map Task Map Task

  6. Improving Efficiency • Large Number of Mappers • HDFS is inefficient for small files. • Use SequenceFile 1 FileName:00001.jpg Contents: 0x45AEF34FD154BF…. FileName: 00002.jpg Contents: 9a1b2ba4d02bd904..... . . . FileName: 0000n.jpg Contents: 9a1b2ba4d02bd904..... SequenceFile 2 n

  7. Improved Version Sequence File Output Block 1 File Block 1 Map Task Output Block 2 File Block 2 Map Task

  8. Example: Sobel Edge Detection • publicstaticclassImagePMapperextends Mapper<Text, BytesWritable, Text, BytesWritable>{ • //Sobel Kernels • float[] xKernel = { • -1.0f, 0.0f, 1.0f, • -2.0f, 0.0f, 2.0f, • -1.0f, 0.0f, 1.0f • }; • float[] yKernel = { • -1.0f, -2.0f, -1.0f, • 0.0f, 0.0f, 0.0f, • 1.0f, 2.0f, 1.0f • };

  9. Example: SobelEdge Detection • publicvoid map(Text key, BytesWritable value, Context context) throwsIOException, InterruptedException{ • //Read Image • InputStream in = newByteArrayInputStream(value.getBytes()); • BufferedImagebImageFromConvert = ImageIO.read(in); • //Perform Sobel Operations on Image • ConvolveOpblurX = newConvolveOp(new Kernel(3, 3, xKernel)); • BufferedImage x = blurX.filter(bImageFromConvert, null); • ConvolveOpblurY = newConvolveOp(new Kernel(3, 3, yKernel)); • BufferedImage y = blurY.filter(x, null);

  10. Example: SobelEdge Detection • //Create Output ByteStream • BytesWritableoutputBytes = newBytesWritable(); • ByteArrayOutputStreambaos = newByteArrayOutputStream(); • ImageIO.write( y, format, baos ); • baos.flush(); • byte[] imageInByte = baos.toByteArray(); • baos.close(); • outputBytes.set(imageInByte, 0, imageInByte.length); • //Send output key,value pairs. • context.write(key, outputBytes); • } • }

  11. Strategy for Large Images Mapper Mapper Reducer Mapper Mapper

More Related