1 / 35

Basic I mage Manipulation

Basic I mage Manipulation. Raed S. Rasheed 2012. Agenda. Region of Interest (ROI) Basic geometric manipulation . Enlarge shrink Reflection Arithmetic and logical combination of images . Addition and averaging. Subtraction. Division. AND & OR . Transformation and Rotation.

nizana
Download Presentation

Basic I mage Manipulation

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. Basic Image Manipulation Raed S. Rasheed 2012

  2. Agenda • Region of Interest (ROI) • Basic geometric manipulation. • Enlarge • shrink • Reflection • Arithmetic and logical combination of images. • Addition and averaging. • Subtraction. • Division. • AND & OR. • Transformation and Rotation

  3. Region of Interest (ROI) • A region of interest (ROI) is a rectangular area within the image, defined either by the coordinates of the pixels at its upper-left and lower-right corners or by the coordinates of its upper-left corner and its dimensions.

  4. Region of Interest (ROI)

  5. Basic Geometric Manipulation. Enlargingor shrinking an image can be accomplished by replicating or skipping pixels. These techniques can be used to magnify small details in an image, or reduce a large image in size so that it fits on the screen. They have the advantage of being fast, but can only resize an image by an integer factor.

  6. Basic Geometric Manipulation. Enlarge: To enlarge an image by an integer factor n, we must replicate pixels such that each pixel in the input image becomes an n x n block of identical pixels in the output image. The most straightforward implementation of this involves iterating over the pixels in the larger output image and computing the coordinates of the input image pixel from which a value must be taken. For a pixel (x, y) in the output image, the corresponding pixel in the input image is at (x/n, y/n). Calculation of the coordinates is done using integer arithmetic.

  7. Basic Geometric Manipulation. ALGORITHM Image_Enlarge 3.1 01 INPUT Image, n 02 OUTPUTEnlargeImage 03 BEGIN 04 Create new image EnlargeImage; // with multiple size (n); 05 For each row in EnlargeImage 06 For each column in EnlargeImage 07 SETEnlargeImage(column,row) = Image(column/n,row/n) 08 END For 09 END For 10 RETURN EnlargeImage; 11 END

  8. Basic Geometric Manipulation.

  9. Basic Geometric Manipulation. Shrink: To shrink an image by an integer factor n, we must sample every nthpixel in the horizontal and vertical dimensions and ignore the others. Again, this technique is most easily implemented by iterating over pixels in the output image and computing the coordinates of the corresponding input image pixel.

  10. Basic Geometric Manipulation. ALGORITHM Image_Shrink 3.2 01 INPUT Image, n 02 OUTPUTShrinkImage 03 BEGIN 04 Create new image ShrinkImage; // with divided size (n) 05 For each row in ShrinkImage 06 For each column in ShrinkImage 07 SETShrinkImage(column,row) = Image(column*n, row*n); 08 END For 09 END For 10 RETURN ShrinkImage; 11 END

  11. Basic Geometric Manipulation.

  12. Basic Geometric Manipulation. Reflection: Reflection along either of the image axes can also be performed in place. This simply involves reversing the ordering of pixels in the rows or columns of the image.

  13. Basic Geometric Manipulation. ALGORITHM Image_Vertical_ Refliction 3.3 01 INPUT Image 02 OUTPUTReflectionImage 03 BEGIN 04 Create new image ReflectionImage; 05 SET W = Image Width; 06 For each row in Image 07 For each column in Image 08 SETReflectionImage(column,row) = Image(W – column – 1,row); 09 END For 10 END For 11 RETURN ReflectionImage; 12 END

  14. Basic Geometric Manipulation.

  15. Arithmetic and logical combination of images. Addition and averaging: I f we add two 8-bit greyscale images, then pixels in the resulting image can have values in the range0 - 510. We should therefore choose a 16-bit representation for the output image or divide every pixel's value by two. If we do the latter, then we are computing an average of the two images. g(x,y) = αf1(x,y) + (1 - α)f2(x,y)

  16. Arithmetic and logical combination of images. α = 0% α = 0% α = 0% α = 0% α = 0% α = 0% α = 0% α = 100% α = 50% α = 50% α = 100% α = 0%

  17. Arithmetic and logical combination of images. ALGORITHM Image_Addition_Averaging 3.4 01 INPUTImage1, Image2, α 02 OUTPUTAddintionImage 03 BEGIN 04 Create new image AddintionImage; 06 For each row in Image1 and Image2 07 For each column in Image1 and Image2 08 SETAddintionImage(column,row) = α * Image1(column,row) + ( 1 - α ) * Image2(column,row); 09 END For 10 END For 11 RETURN AddintionImage; 12 END

  18. Arithmetic and logical combination of images. Subtraction: Subtracting two 8-bit greyscale images can produce values between -255 and +255. This necessitates the use of 16-bit signed integers in the output image unless sign is unimportant, in which case we can simply take the modulus of the result and store it using 8-bit integers: g(x,y) = |f1(x,y) - f2(x,y)|

  19. Arithmetic and logical combination of images. ALGORITHM Image_Subtraction 3.5 01 INPUTImage1, Image2 02 OUTPUTSubtractionImage 03 BEGIN 04 Create new image SubtractionImage; 06 For each row in Image1 and Image2 07 For each column in Image1 and Image2 08 SETSubtractionImage(column,row) = | Image1(column,row) - Image2(column,row) |; 09 END For 10 END For 11 RETURN SubtractionImage; 12 END

  20. Arithmetic and logical combination of images. Subtraction:

  21. Arithmetic and logical combination of images. Division: For division of images to produce meaningful results, floating-point arithmetic must be used. The ratio image can be of the floating-point type, or we can rescale and round pixel values to be in a more convenient 0-255 range.

  22. Arithmetic and logical combination of images. ALGORITHM Image_Division3.5 01 INPUTImage1, Image2 02 OUTPUTDivisionImage 03 BEGIN 04 Create new image DivisionImage; 06 For each row in Image1 and Image2 07 For each column in Image1 and Image2 08 SETDivisionImage(column,row) = Rescale(Image1(column,row) / Image2(column,row)); 09 END For 10 END For 11 RETURN DivisionImage; 12 END

  23. Arithmetic and logical combination of images. Division:

  24. Arithmetic and logical combination of images. AND & OR: Logical AND andOR operations are useful for the masking and compositing of images. For example, if we compute the AND of a binary image with some other image, then pixels for which the corresponding value in the binary image is 1 will be preserved, but pixels for which the corresponding binary value is 0 will be set to 0 themselves. Thus the binary image acts as a 'mask' that removes information from certain parts of the image.

  25. Arithmetic and logical combination of images. ALGORITHM Image_AND 3.6 01 INPUTImage1, Image2 02 OUTPUTANDImage 03 BEGIN 04 Create new image ANDImage; 06 For each row in Image1 and Image2 07 For each column in Image1 and Image2 08 SETANDImage(column,row) = Image1(column,row) AND Image2(column,row); 09 END For 10 END For 11 RETURN ANDImage; 12 END

  26. Arithmetic and logical combination of images. ALGORITHM Image_OR 3.7 01 INPUTImage1, Image2 02 OUTPUTORImage 03 BEGIN 04 Create new image ORImage; 06 For each row in Image1 and Image2 07 For each column in Image1 and Image2 08 SETORImage(column,row) = Image1(column,row) OR Image2(column,row); 09 END For 10 END For 11 RETURN ORImage; 12 END

  27. Arithmetic and logical combination of images. AND & OR:

  28. Arithmetic and logical combination of images. AND & OR:

  29. Transformation and Rotation

  30. Transformation and Rotation ALGORITHM Image_Transformation 3.8 01 INPUTImage, Tx ,Ty 02 OUTPUTTransformationImage 03 BEGIN 04 Create new image TransformationImage; 06 For each row in Image 07 Foreach column in Image 08 SETNewCol = column + Tx; 09 SETNewRow= row + Ty; 10 SETTransformationImage(NewCol,NewRow) = Image(column,row); 11 END For 12 END For 13 RETURN TransformationImage; 14 END

  31. Transformation and Rotation

  32. Transformation and Rotation • The pixel at (0, 100) after a 90° rotation • The pixel at (50, 0) after a 35° rotation x' = x cosθ - y sin θ = 50 cos(35o ) = 40.96, y' = x sin θ + y cosθ = 50 sin(35o ) = 28.68. In case 1, cos 90' is 0 and sin 90' is 1, so the pixel moves to coordinates (-100,0). This is clearly a problem, since pixels cannot have negative coordinates. Case 2 illustrates a different problem.

  33. Transformation and Rotation The first problem can be solved by testing coordinates to check that they lie within the bounds of the output image before attempting to copy pixel values. A simple solution to the second problem is to find the nearest integers to x' and y' and use these as the coordinates of the transformed pixel.

  34. Transformation and Rotation ALGORITHM Image_Rotation3.9 01 INPUTImage, θ 02 OUTPUTRotationImage 03 BEGIN 04 Create new image RotationImage; 05 SETa0= Cos(θ), b0= Sin(θ), a1= - b0, b1= a0; 06 For each row in Image 07 Foreach column in Image 08 SETNewCol = Round(a0 * column + a1 * row); 09 SETNewRow= Round(b0* column + b1* row); 10 IFNewColANDNewRowinside RotationImageTHEN 11 SETRotationImage(NewCol,NewRow) = Image(column,row); 12 END IF 13 END For 14 END For 15 RETURN RotationImage; 16 END

  35. Transformation and Rotation

More Related