diff --git a/README.md b/README.md index e69de29..9b1d0a6 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,63 @@ +# Computer Graphics Course Project + +A comprehensive Java application for Computer Graphics image processing operations. + +![Project Image](images/image.png) + +## Project Structure + +``` +Computer_Graphics/ +├── src/ # Java source files +├── bin/ # Compiled .class files +├── images/ # Input/output image files (BMP, JPG, PNG, GIF) +│ └── image.png # Project screenshot/diagram +├── compile.sh # Build script +└── README.md # This file +``` + +## Features + +This project includes various image processing operations: + +- **Image Operations**: Addition, Subtraction, Blending, Masking, Stitching +- **Transformations**: Rotation, Shearing, Resizing, Cropping, Flipping +- **Histogram Operations**: Stretching, Equalization, Matching +- **Filtering**: Convolution, Unsharp Masking, Binary Thresholding +- **Advanced**: Bit Plane Slicing, Block Averaging, Steganography + +## Compilation + +To compile the project: + +```bash +javac -d bin src/*.java +``` + +## Execution + +To run the application: + +```bash +java -cp bin Main +``` + +Or alternatively: + +```bash +cd bin +java Main +``` + +## Image Files + +- Input images should be placed in the `images/` directory +- All output images will be saved to the `images/` directory +- Supported formats: BMP, JPG, JPEG, PNG, GIF + +## Notes + +- The application uses a GUI interface (Screen.java) to access various image processing operations +- All image paths in the code reference the `images/` directory +- Output files are automatically saved with `.bmp` extension in the `images/` directory + diff --git a/bin/BinaryThresholding.class b/bin/BinaryThresholding.class new file mode 100644 index 0000000..1a19072 Binary files /dev/null and b/bin/BinaryThresholding.class differ diff --git a/bin/BitPlaneSlicing.class b/bin/BitPlaneSlicing.class new file mode 100644 index 0000000..069c81c Binary files /dev/null and b/bin/BitPlaneSlicing.class differ diff --git a/bin/BlockAveraging.class b/bin/BlockAveraging.class new file mode 100644 index 0000000..5b78287 Binary files /dev/null and b/bin/BlockAveraging.class differ diff --git a/bin/BrightnessContrastAdjustment.class b/bin/BrightnessContrastAdjustment.class new file mode 100644 index 0000000..f0bb699 Binary files /dev/null and b/bin/BrightnessContrastAdjustment.class differ diff --git a/bin/CheckerboardImageGenerator.class b/bin/CheckerboardImageGenerator.class new file mode 100644 index 0000000..3d1321b Binary files /dev/null and b/bin/CheckerboardImageGenerator.class differ diff --git a/bin/GrayScalePattern.class b/bin/GrayScalePattern.class new file mode 100644 index 0000000..1c43397 Binary files /dev/null and b/bin/GrayScalePattern.class differ diff --git a/bin/Histogram.class b/bin/Histogram.class new file mode 100644 index 0000000..3037595 Binary files /dev/null and b/bin/Histogram.class differ diff --git a/bin/HistogramEqualization.class b/bin/HistogramEqualization.class new file mode 100644 index 0000000..664b616 Binary files /dev/null and b/bin/HistogramEqualization.class differ diff --git a/bin/HistogramMatching.class b/bin/HistogramMatching.class new file mode 100644 index 0000000..33bc81e Binary files /dev/null and b/bin/HistogramMatching.class differ diff --git a/bin/HistogramStretching.class b/bin/HistogramStretching.class new file mode 100644 index 0000000..4222ae8 Binary files /dev/null and b/bin/HistogramStretching.class differ diff --git a/bin/ImageAdditionInversion.class b/bin/ImageAdditionInversion.class new file mode 100644 index 0000000..a03458a Binary files /dev/null and b/bin/ImageAdditionInversion.class differ diff --git a/bin/ImageBlending.class b/bin/ImageBlending.class new file mode 100644 index 0000000..2dabd22 Binary files /dev/null and b/bin/ImageBlending.class differ diff --git a/bin/ImageConvolution.class b/bin/ImageConvolution.class new file mode 100644 index 0000000..6484ef6 Binary files /dev/null and b/bin/ImageConvolution.class differ diff --git a/bin/ImageCropFlip.class b/bin/ImageCropFlip.class new file mode 100644 index 0000000..a6dde45 Binary files /dev/null and b/bin/ImageCropFlip.class differ diff --git a/bin/ImageMasking.class b/bin/ImageMasking.class new file mode 100644 index 0000000..bafea96 Binary files /dev/null and b/bin/ImageMasking.class differ diff --git a/bin/ImageResize.class b/bin/ImageResize.class new file mode 100644 index 0000000..16cdc80 Binary files /dev/null and b/bin/ImageResize.class differ diff --git a/bin/ImageRotation.class b/bin/ImageRotation.class new file mode 100644 index 0000000..d5a998d Binary files /dev/null and b/bin/ImageRotation.class differ diff --git a/bin/ImageShearing.class b/bin/ImageShearing.class new file mode 100644 index 0000000..28fe23a Binary files /dev/null and b/bin/ImageShearing.class differ diff --git a/bin/ImageSteganography.class b/bin/ImageSteganography.class new file mode 100644 index 0000000..3d3d690 Binary files /dev/null and b/bin/ImageSteganography.class differ diff --git a/bin/ImageStitching.class b/bin/ImageStitching.class new file mode 100644 index 0000000..99f6838 Binary files /dev/null and b/bin/ImageStitching.class differ diff --git a/bin/ImageSubtraction.class b/bin/ImageSubtraction.class new file mode 100644 index 0000000..5f1bdff Binary files /dev/null and b/bin/ImageSubtraction.class differ diff --git a/bin/Main.class b/bin/Main.class new file mode 100644 index 0000000..7092cb3 Binary files /dev/null and b/bin/Main.class differ diff --git a/bin/OpenBB.class b/bin/OpenBB.class new file mode 100644 index 0000000..3414eea Binary files /dev/null and b/bin/OpenBB.class differ diff --git a/bin/Screen$1.class b/bin/Screen$1.class new file mode 100644 index 0000000..d954812 Binary files /dev/null and b/bin/Screen$1.class differ diff --git a/bin/Screen$10.class b/bin/Screen$10.class new file mode 100644 index 0000000..c938407 Binary files /dev/null and b/bin/Screen$10.class differ diff --git a/bin/Screen$11.class b/bin/Screen$11.class new file mode 100644 index 0000000..e7db049 Binary files /dev/null and b/bin/Screen$11.class differ diff --git a/bin/Screen$12.class b/bin/Screen$12.class new file mode 100644 index 0000000..d27829c Binary files /dev/null and b/bin/Screen$12.class differ diff --git a/bin/Screen$13.class b/bin/Screen$13.class new file mode 100644 index 0000000..f7251bb Binary files /dev/null and b/bin/Screen$13.class differ diff --git a/bin/Screen$14.class b/bin/Screen$14.class new file mode 100644 index 0000000..0f74b11 Binary files /dev/null and b/bin/Screen$14.class differ diff --git a/bin/Screen$15.class b/bin/Screen$15.class new file mode 100644 index 0000000..52fcd19 Binary files /dev/null and b/bin/Screen$15.class differ diff --git a/bin/Screen$16.class b/bin/Screen$16.class new file mode 100644 index 0000000..b50aa47 Binary files /dev/null and b/bin/Screen$16.class differ diff --git a/bin/Screen$17.class b/bin/Screen$17.class new file mode 100644 index 0000000..1ccdac2 Binary files /dev/null and b/bin/Screen$17.class differ diff --git a/bin/Screen$18.class b/bin/Screen$18.class new file mode 100644 index 0000000..86a1cb1 Binary files /dev/null and b/bin/Screen$18.class differ diff --git a/bin/Screen$19.class b/bin/Screen$19.class new file mode 100644 index 0000000..427a004 Binary files /dev/null and b/bin/Screen$19.class differ diff --git a/bin/Screen$2.class b/bin/Screen$2.class new file mode 100644 index 0000000..499f919 Binary files /dev/null and b/bin/Screen$2.class differ diff --git a/bin/Screen$20.class b/bin/Screen$20.class new file mode 100644 index 0000000..d253161 Binary files /dev/null and b/bin/Screen$20.class differ diff --git a/bin/Screen$21.class b/bin/Screen$21.class new file mode 100644 index 0000000..575a4d5 Binary files /dev/null and b/bin/Screen$21.class differ diff --git a/bin/Screen$22.class b/bin/Screen$22.class new file mode 100644 index 0000000..173ac08 Binary files /dev/null and b/bin/Screen$22.class differ diff --git a/bin/Screen$23.class b/bin/Screen$23.class new file mode 100644 index 0000000..19acf4a Binary files /dev/null and b/bin/Screen$23.class differ diff --git a/bin/Screen$24.class b/bin/Screen$24.class new file mode 100644 index 0000000..7dcc479 Binary files /dev/null and b/bin/Screen$24.class differ diff --git a/bin/Screen$25.class b/bin/Screen$25.class new file mode 100644 index 0000000..3c98318 Binary files /dev/null and b/bin/Screen$25.class differ diff --git a/bin/Screen$26.class b/bin/Screen$26.class new file mode 100644 index 0000000..6c319b7 Binary files /dev/null and b/bin/Screen$26.class differ diff --git a/bin/Screen$27.class b/bin/Screen$27.class new file mode 100644 index 0000000..d6f84e5 Binary files /dev/null and b/bin/Screen$27.class differ diff --git a/bin/Screen$28.class b/bin/Screen$28.class new file mode 100644 index 0000000..f28c50d Binary files /dev/null and b/bin/Screen$28.class differ diff --git a/bin/Screen$29.class b/bin/Screen$29.class new file mode 100644 index 0000000..f3dae63 Binary files /dev/null and b/bin/Screen$29.class differ diff --git a/bin/Screen$3.class b/bin/Screen$3.class new file mode 100644 index 0000000..9be7eb1 Binary files /dev/null and b/bin/Screen$3.class differ diff --git a/bin/Screen$4.class b/bin/Screen$4.class new file mode 100644 index 0000000..c939a6b Binary files /dev/null and b/bin/Screen$4.class differ diff --git a/bin/Screen$5.class b/bin/Screen$5.class new file mode 100644 index 0000000..3226246 Binary files /dev/null and b/bin/Screen$5.class differ diff --git a/bin/Screen$6.class b/bin/Screen$6.class new file mode 100644 index 0000000..8f012be Binary files /dev/null and b/bin/Screen$6.class differ diff --git a/bin/Screen$7.class b/bin/Screen$7.class new file mode 100644 index 0000000..308232f Binary files /dev/null and b/bin/Screen$7.class differ diff --git a/bin/Screen$8.class b/bin/Screen$8.class new file mode 100644 index 0000000..d2b0b37 Binary files /dev/null and b/bin/Screen$8.class differ diff --git a/bin/Screen$9.class b/bin/Screen$9.class new file mode 100644 index 0000000..6e71938 Binary files /dev/null and b/bin/Screen$9.class differ diff --git a/bin/Screen.class b/bin/Screen.class new file mode 100644 index 0000000..be66818 Binary files /dev/null and b/bin/Screen.class differ diff --git a/bin/UnsharpMasking.class b/bin/UnsharpMasking.class new file mode 100644 index 0000000..607bd60 Binary files /dev/null and b/bin/UnsharpMasking.class differ diff --git a/compile.sh b/compile.sh new file mode 100755 index 0000000..b819b53 --- /dev/null +++ b/compile.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Compiling Java source files..." +mkdir -p bin +javac -d bin src/*.java + +if [ $? -eq 0 ]; then + echo "Compilation successful!" + echo "Run the application with: java -cp bin Main" +else + echo "Compilation failed!" + exit 1 +fi + diff --git a/images/Imbw.bmp b/images/Imbw.bmp new file mode 100644 index 0000000..0a542e9 Binary files /dev/null and b/images/Imbw.bmp differ diff --git a/images/Imcheck.bmp b/images/Imcheck.bmp new file mode 100644 index 0000000..db95a8f Binary files /dev/null and b/images/Imcheck.bmp differ diff --git a/images/LenaDark.png b/images/LenaDark.png new file mode 100644 index 0000000..e514850 Binary files /dev/null and b/images/LenaDark.png differ diff --git a/images/LenaDark_multC.bmp b/images/LenaDark_multC.bmp new file mode 100644 index 0000000..05c4aa5 Binary files /dev/null and b/images/LenaDark_multC.bmp differ diff --git a/images/LenaDark_strech.bmp b/images/LenaDark_strech.bmp new file mode 100644 index 0000000..170e39e Binary files /dev/null and b/images/LenaDark_strech.bmp differ diff --git a/images/P1_out1.bmp b/images/P1_out1.bmp new file mode 100644 index 0000000..b22a684 Binary files /dev/null and b/images/P1_out1.bmp differ diff --git a/images/P1_out1_b.bmp b/images/P1_out1_b.bmp new file mode 100644 index 0000000..b3d5c59 Binary files /dev/null and b/images/P1_out1_b.bmp differ diff --git a/images/P1_out2.bmp b/images/P1_out2.bmp new file mode 100644 index 0000000..5adb2ae Binary files /dev/null and b/images/P1_out2.bmp differ diff --git a/images/P4_out1.bmp b/images/P4_out1.bmp new file mode 100644 index 0000000..f77334d Binary files /dev/null and b/images/P4_out1.bmp differ diff --git a/images/P9_out1.bmp b/images/P9_out1.bmp new file mode 100644 index 0000000..4f5bc07 Binary files /dev/null and b/images/P9_out1.bmp differ diff --git a/images/Pl-out3.bmp b/images/Pl-out3.bmp new file mode 100644 index 0000000..024de05 Binary files /dev/null and b/images/Pl-out3.bmp differ diff --git a/images/ThS1.jpg b/images/ThS1.jpg new file mode 100644 index 0000000..5fc2af9 Binary files /dev/null and b/images/ThS1.jpg differ diff --git a/images/ThS1_bin.bmp b/images/ThS1_bin.bmp new file mode 100644 index 0000000..d672250 Binary files /dev/null and b/images/ThS1_bin.bmp differ diff --git a/images/ThS1_bin2.bmp b/images/ThS1_bin2.bmp new file mode 100644 index 0000000..912da08 Binary files /dev/null and b/images/ThS1_bin2.bmp differ diff --git a/images/ThS2.jpg b/images/ThS2.jpg new file mode 100644 index 0000000..20ab691 Binary files /dev/null and b/images/ThS2.jpg differ diff --git a/images/a.bmp b/images/a.bmp new file mode 100644 index 0000000..b3578d7 Binary files /dev/null and b/images/a.bmp differ diff --git a/images/b.bmp b/images/b.bmp new file mode 100644 index 0000000..1fd9516 Binary files /dev/null and b/images/b.bmp differ diff --git a/images/balloon.bmp b/images/balloon.bmp new file mode 100644 index 0000000..185c552 Binary files /dev/null and b/images/balloon.bmp differ diff --git a/images/balloon_part.bmp b/images/balloon_part.bmp new file mode 100644 index 0000000..6569775 Binary files /dev/null and b/images/balloon_part.bmp differ diff --git a/images/balloon_part3.bmp b/images/balloon_part3.bmp new file mode 100644 index 0000000..996e207 Binary files /dev/null and b/images/balloon_part3.bmp differ diff --git a/images/barbara.jpg b/images/barbara.jpg new file mode 100644 index 0000000..2bc4903 Binary files /dev/null and b/images/barbara.jpg differ diff --git a/images/bird.bmp b/images/bird.bmp new file mode 100644 index 0000000..84dc132 Binary files /dev/null and b/images/bird.bmp differ diff --git a/images/blured.bmp b/images/blured.bmp new file mode 100644 index 0000000..b3578d7 Binary files /dev/null and b/images/blured.bmp differ diff --git a/images/c.bmp b/images/c.bmp new file mode 100644 index 0000000..8f9104f Binary files /dev/null and b/images/c.bmp differ diff --git a/images/camera_rotated_45.bmp b/images/camera_rotated_45.bmp new file mode 100644 index 0000000..fdd35dc Binary files /dev/null and b/images/camera_rotated_45.bmp differ diff --git a/images/cameraman.jpg b/images/cameraman.jpg new file mode 100644 index 0000000..38d66a2 Binary files /dev/null and b/images/cameraman.jpg differ diff --git a/images/cameraman_shear.bmp.bmp b/images/cameraman_shear.bmp.bmp new file mode 100644 index 0000000..33af84b Binary files /dev/null and b/images/cameraman_shear.bmp.bmp differ diff --git a/images/cars1.bmp b/images/cars1.bmp new file mode 100644 index 0000000..b8dee13 Binary files /dev/null and b/images/cars1.bmp differ diff --git a/images/cars2.bmp b/images/cars2.bmp new file mode 100644 index 0000000..cba1a8b Binary files /dev/null and b/images/cars2.bmp differ diff --git a/images/cars3.bmp b/images/cars3.bmp new file mode 100644 index 0000000..89f0a11 Binary files /dev/null and b/images/cars3.bmp differ diff --git a/images/carsl_brighten.bmp b/images/carsl_brighten.bmp new file mode 100644 index 0000000..0a8ddb5 Binary files /dev/null and b/images/carsl_brighten.bmp differ diff --git a/images/crowd.jpg b/images/crowd.jpg new file mode 100644 index 0000000..6cc355a Binary files /dev/null and b/images/crowd.jpg differ diff --git a/images/crowd_equal.bmp b/images/crowd_equal.bmp new file mode 100644 index 0000000..6feaedb Binary files /dev/null and b/images/crowd_equal.bmp differ diff --git a/images/d.bmp b/images/d.bmp new file mode 100644 index 0000000..91595f8 Binary files /dev/null and b/images/d.bmp differ diff --git a/images/e.bmp b/images/e.bmp new file mode 100644 index 0000000..5baa3be Binary files /dev/null and b/images/e.bmp differ diff --git a/images/f.bmp b/images/f.bmp new file mode 100644 index 0000000..b11eed4 Binary files /dev/null and b/images/f.bmp differ diff --git a/images/g.bmp b/images/g.bmp new file mode 100644 index 0000000..2184aca Binary files /dev/null and b/images/g.bmp differ diff --git a/images/girl.jpg b/images/girl.jpg new file mode 100644 index 0000000..3f65940 Binary files /dev/null and b/images/girl.jpg differ diff --git a/images/girl_16.bmp b/images/girl_16.bmp new file mode 100644 index 0000000..328e921 Binary files /dev/null and b/images/girl_16.bmp differ diff --git a/images/girl_32.bmp b/images/girl_32.bmp new file mode 100644 index 0000000..1acdd9b Binary files /dev/null and b/images/girl_32.bmp differ diff --git a/images/girl_4.bmp b/images/girl_4.bmp new file mode 100644 index 0000000..35342ac Binary files /dev/null and b/images/girl_4.bmp differ diff --git a/images/girl_8.bmp b/images/girl_8.bmp new file mode 100644 index 0000000..6d57816 Binary files /dev/null and b/images/girl_8.bmp differ diff --git a/images/h.bmp b/images/h.bmp new file mode 100644 index 0000000..8438508 Binary files /dev/null and b/images/h.bmp differ diff --git a/images/house.jpg b/images/house.jpg new file mode 100644 index 0000000..ec2606b Binary files /dev/null and b/images/house.jpg differ diff --git a/images/hw3.bmp b/images/hw3.bmp new file mode 100644 index 0000000..02464fb Binary files /dev/null and b/images/hw3.bmp differ diff --git a/images/hw5_1.bmp b/images/hw5_1.bmp new file mode 100644 index 0000000..f05c984 Binary files /dev/null and b/images/hw5_1.bmp differ diff --git a/images/hw5_2.bmp b/images/hw5_2.bmp new file mode 100644 index 0000000..7ccf9db Binary files /dev/null and b/images/hw5_2.bmp differ diff --git a/images/i.bmp b/images/i.bmp new file mode 100644 index 0000000..2db7bef Binary files /dev/null and b/images/i.bmp differ diff --git a/images/image.png b/images/image.png new file mode 100644 index 0000000..d946f68 Binary files /dev/null and b/images/image.png differ diff --git a/images/input1.jpg b/images/input1.jpg new file mode 100644 index 0000000..cb180b1 Binary files /dev/null and b/images/input1.jpg differ diff --git a/images/input2.jpg b/images/input2.jpg new file mode 100644 index 0000000..df266df Binary files /dev/null and b/images/input2.jpg differ diff --git a/images/j.bmp b/images/j.bmp new file mode 100644 index 0000000..9bc1d5b Binary files /dev/null and b/images/j.bmp differ diff --git a/images/k.bmp b/images/k.bmp new file mode 100644 index 0000000..a66fb14 Binary files /dev/null and b/images/k.bmp differ diff --git a/images/l.bmp b/images/l.bmp new file mode 100644 index 0000000..b2d7d71 Binary files /dev/null and b/images/l.bmp differ diff --git a/images/lena.jpg b/images/lena.jpg new file mode 100644 index 0000000..d2725c6 Binary files /dev/null and b/images/lena.jpg differ diff --git a/images/lena2.jpg b/images/lena2.jpg new file mode 100644 index 0000000..d2725c6 Binary files /dev/null and b/images/lena2.jpg differ diff --git a/images/matching.bmp b/images/matching.bmp new file mode 100644 index 0000000..d258b2f Binary files /dev/null and b/images/matching.bmp differ diff --git a/images/message.bmp b/images/message.bmp new file mode 100644 index 0000000..c004fa5 Binary files /dev/null and b/images/message.bmp differ diff --git a/images/pigeon.jpg b/images/pigeon.jpg new file mode 100644 index 0000000..59528a7 Binary files /dev/null and b/images/pigeon.jpg differ diff --git a/images/soldier.jpg b/images/soldier.jpg new file mode 100644 index 0000000..65ef235 Binary files /dev/null and b/images/soldier.jpg differ diff --git a/images/street.jpg b/images/street.jpg new file mode 100644 index 0000000..edbf210 Binary files /dev/null and b/images/street.jpg differ diff --git a/images/temp.bmp b/images/temp.bmp new file mode 100644 index 0000000..c6c0de1 Binary files /dev/null and b/images/temp.bmp differ diff --git a/images/temp2.bmp b/images/temp2.bmp new file mode 100644 index 0000000..e11d296 Binary files /dev/null and b/images/temp2.bmp differ diff --git a/images/test.bmp b/images/test.bmp new file mode 100644 index 0000000..cbee786 Binary files /dev/null and b/images/test.bmp differ diff --git a/images/trn.gif b/images/trn.gif new file mode 100644 index 0000000..3414dbb Binary files /dev/null and b/images/trn.gif differ diff --git a/images/trn_log.bmp b/images/trn_log.bmp new file mode 100644 index 0000000..e8f1daa Binary files /dev/null and b/images/trn_log.bmp differ diff --git a/images/trn_pow_log.bmp b/images/trn_pow_log.bmp new file mode 100644 index 0000000..02f74da Binary files /dev/null and b/images/trn_pow_log.bmp differ diff --git a/images/wom.gif b/images/wom.gif new file mode 100644 index 0000000..ab3ae4b Binary files /dev/null and b/images/wom.gif differ diff --git a/images/wom_log.bmp b/images/wom_log.bmp new file mode 100644 index 0000000..1a5f819 Binary files /dev/null and b/images/wom_log.bmp differ diff --git a/images/wom_pow_log.bmp b/images/wom_pow_log.bmp new file mode 100644 index 0000000..5a2e1fd Binary files /dev/null and b/images/wom_pow_log.bmp differ diff --git a/src/BinaryThresholding.java b/src/BinaryThresholding.java new file mode 100644 index 0000000..1bc2a86 --- /dev/null +++ b/src/BinaryThresholding.java @@ -0,0 +1,77 @@ +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.nio.channels.ShutdownChannelGroupException; + +import javax.imageio.ImageIO; + +public class BinaryThresholding extends OpenBB{ + + private Image image,image2,image3,image4; + private int[] histogram,histogram2; + + public BinaryThresholding(){ + + try { + //------ homework 1 part a and b ---------- + image = ImageIO.read(new File("images/ThS1.jpg")); + histogram = calHistogram(image); + int[][] imageMatrix = imageToMatrix((BufferedImage)image); + int[][] im = imageMatrix; + for(int i=0 ; i100)im[i][j] = 0; + else im[i][j] = 255; + } + } + image2 = matrixToImage("ThS1_bin", im); + + // ----- homework 1 part c ------- + image3 = ImageIO.read(new File("images/ThS2.jpg")); + histogram2 = new int[256]; + for(int i=0; i<255; i++) + histogram2[i]= 0; + int[][] imageMatrix2 = imageToMatrix((BufferedImage)image3); + for(int i=0 ; i120)im2[i][j] = 255; + else im2[i][j] = 0; + } + } + image4 = matrixToImage("ThS1_bin2", im2); + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +public Image getImage(){ + return image; +} +public int[] getImageHistogram(){ + return histogram; +} +public Image getImage2(){ + return image2; +} +public Image getImage3(){ + return image3; +} +public Image getImage4(){ + return image4; +} +public int[] getImageHistogram2(){ + return histogram2; +} + +} \ No newline at end of file diff --git a/src/BitPlaneSlicing.java b/src/BitPlaneSlicing.java new file mode 100644 index 0000000..5df9d76 --- /dev/null +++ b/src/BitPlaneSlicing.java @@ -0,0 +1,97 @@ + +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class BitPlaneSlicing extends OpenBB{ + + public Image bird8,bird7,bird6,bird5,bird4,bird3,bird2,bird1; + public int[][] b8,b7,b6,b5,b4,b3,b2,b1; + public BitPlaneSlicing(){ + + try { + bird8 = ImageIO.read(new File("images/bird.bmp")); + b8 = new int[991][637]; + b7 = new int[991][637]; + b6 = new int[991][637]; + b5 = new int[991][637]; + b4 = new int[991][637]; + b3 = new int[991][637]; + b2 = new int[991][637]; + + b8 = imageToMatrix((BufferedImage)bird8); + bird7 = shiftLike("P5_out7",b8,2); + b7 = imageToMatrix((BufferedImage)bird7); + bird6 = shiftLike("P5_out6",b7,4); + b6 = imageToMatrix((BufferedImage)bird6); + bird5 = shiftLike("P5_out5",b6,8); + b5 = imageToMatrix((BufferedImage)bird5); + bird4 = shiftLike("P5_out4",b5,16); + b4 = imageToMatrix((BufferedImage)bird4); + bird3 = shiftLike("P5_out3",b4,32); + b3 = imageToMatrix((BufferedImage)bird3); + bird2 = shiftLike("P5_out2",b3,64); + b2 = imageToMatrix((BufferedImage)bird2); + bird1 = shiftLike("P5_out1",b2,128); + + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + + + public Image shiftLike(String name,int[][] b, int k){ + + for(int i=0; i255)girlP[p][q]= 255; + else if((int)(Ave/(bsize[b]*bsize[b]))<0)girlP[p][q] = 0; + else + girlP[p][q] = (int)(Ave/(bsize[b]*bsize[b])); + } + } + + } + } + + girls[b] = matrixToImage("girl_"+bsize[b],girlP); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + + public Image getImage(int i){ + return girls[i-1]; + } + +} diff --git a/src/BrightnessContrastAdjustment.java b/src/BrightnessContrastAdjustment.java new file mode 100644 index 0000000..6c6762a --- /dev/null +++ b/src/BrightnessContrastAdjustment.java @@ -0,0 +1,82 @@ + +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class BrightnessContrastAdjustment extends OpenBB{ + + String imageName1 = "carsl_brighten"; + String imageName2 = "cars_mult"; + + Image image, originalImage; + int[][] imagePixels; + double contrast; + + public BrightnessContrastAdjustment(double c, int d){ + + if(d ==1){ + try { + contrast = c; + originalImage = ImageIO.read(new File("images/cars1.bmp")); + imagePixels = new int[200][150]; + imagePixels = imageToMatrix((BufferedImage)originalImage); + for(int i=0; i<200; i++){ + for(int j=0; j<150; j++){ + if(imagePixels[i][j]+c >255) + imagePixels[i][j] = 255; + else + imagePixels[i][j] = (int)(imagePixels[i][j]+c); + } + } + + image = matrixToImage(imageName1,imagePixels); + + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else{ + try { + contrast = c; + originalImage = ImageIO.read(new File("images/cars1.bmp")); + imagePixels = new int[200][150]; + imagePixels = imageToMatrix((BufferedImage)originalImage); + for(int i=0; i<200; i++){ + for(int j=0; j<150; j++){ + if(imagePixels[i][j]*c >255) + imagePixels[i][j] = 255; + else + imagePixels[i][j] = (int)(imagePixels[i][j]*c); + } + } + + image = matrixToImage(imageName2,imagePixels); + + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + + + + +public Image getImage(){ + return image; +} +public Image getOriginalImage(){ + return originalImage; +} + +} \ No newline at end of file diff --git a/src/CheckerboardImageGenerator.java b/src/CheckerboardImageGenerator.java new file mode 100644 index 0000000..e4ff23f --- /dev/null +++ b/src/CheckerboardImageGenerator.java @@ -0,0 +1,90 @@ +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class CheckerboardImageGenerator extends OpenBB{ + + private Image image,image2; + + public CheckerboardImageGenerator(){ + + init(); + init2(); + + } + + +private void init() { + + try { + String imageName = "Imcheck"; + int[][] gray = new int[400][400]; + int[][] green = new int[400][400]; + int[][] blue = new int[400][400]; + + for(int i=0; i<400; i++){ + for(int j=0; j<400; j++){ + int z = (int)(j/50); + int k = (int)(i/50); + if(z%2 == 0){ + if(k%2==0) + gray[i][j] = green[i][j] = blue[i][j] = 0; + else + gray[i][j] = green[i][j] = blue[i][j] = 255; + } + else{ + if(k%2!=0) + gray[i][j] = green[i][j] = blue[i][j] = 0; + else + gray[i][j] = green[i][j] = blue[i][j] = 255; + + } + } + } + + image = matrixToImage(imageName,gray); + image = ImageIO.read(new File("images/"+imageName+".bmp")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + +private void init2() { + + try { + String imageName = "Imbw"; + int[][] red = new int[400][400]; + int[][] green = new int[400][400]; + int[][] blue = new int[400][400]; + for(int i=0; i<400;i++){ + for(int j=0; j<400; j++){ + if(i>200) + red[i][j] = green[i][j] = blue[i][j] = 0; + else + red[i][j] = green[i][j] = blue[i][j] = 255; + + } + } + image2 = createImage(imageName,red,green,blue); + image2 = ImageIO.read(new File("images/"+imageName+".bmp")); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } +public Image getImage(){ + return image; +} +public Image getImage2(){ + return image2; +} +} diff --git a/src/GrayScalePattern.java b/src/GrayScalePattern.java new file mode 100644 index 0000000..6bef55a --- /dev/null +++ b/src/GrayScalePattern.java @@ -0,0 +1,39 @@ + +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; + +import javax.imageio.ImageIO; + +public class GrayScalePattern extends OpenBB{ + + private Image img; + + public GrayScalePattern(){ + + int[][] grayScale = new int[256][256]; + for(int dx = 0; dx<256; dx+=10){ + for(int i=dx; i<256 - dx; i++){ + for(int j=dx; j<256 - dx; j++){ + + grayScale[i][j] = dx; + + } + } + } + img = matrixToImage("P4_out1",grayScale); + + } + + + + + public Image getImage() { + return img; + } + + + +} diff --git a/src/Histogram.java b/src/Histogram.java new file mode 100644 index 0000000..39e8586 --- /dev/null +++ b/src/Histogram.java @@ -0,0 +1,40 @@ +import java.awt.Color; +import java.awt.Graphics; + +public class Histogram { + + private int[] histogram; + private Graphics g; + + public Histogram(int[] his, Graphics gra,int x, int y, int l){ + histogram = his; + g = gra; + int max = maxElementInArray(histogram); + int t = max/l; + int[] up = new int[histogram.length]; + for(int i=0; imax)max = arr[i]; + } + return max; + } + + +} + diff --git a/src/HistogramEqualization.java b/src/HistogramEqualization.java new file mode 100644 index 0000000..18e0650 --- /dev/null +++ b/src/HistogramEqualization.java @@ -0,0 +1,112 @@ +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class HistogramEqualization extends OpenBB{ + + Image image, image2,image3, image4; + int[][] imageMatrix = { + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}, + {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0}}; + int[] histogram, histogram2,histogram3, histogram4; + + double[][] table; + int[][] imageMatrix2,imageMatrix3,imageMatrix4; + + public HistogramEqualization(){ + + for(int i=0; i 255) + image3Pixels[i][j] = 255; + else + image3Pixels[i][j]= image2Pixels[i][j]+imagePixels[i][j]; + + + if(image4Pixels[i][j] == 255){ + image4Pixels[i][j] = 0; + }else{ + image4Pixels[i][j] = 255; + } + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public Image getImage3(){ + return image3; + } + public Image getImage4(){ + return image4; + } + + + + +} diff --git a/src/ImageBlending.java b/src/ImageBlending.java new file mode 100644 index 0000000..f18e7ac --- /dev/null +++ b/src/ImageBlending.java @@ -0,0 +1,71 @@ + +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageBlending extends OpenBB{ + + Image car1,car2,car3; + int[][] car1P,car2P,car3P; + Image image; + int[][] imageP; + String imageN; + + public ImageBlending(){ + try { + car1 = ImageIO.read(new File("images/cars1.bmp")); + car2 = ImageIO.read(new File("images/cars2.bmp")); + car3 = ImageIO.read(new File("images/cars3.bmp")); + imageN = "cars_blending"; + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + car1P = new int[200][150]; + car2P = new int[200][150]; + car3P = new int[200][150]; + imageP = new int[200][150]; + car1P = imageToMatrix((BufferedImage)car1); + car2P = imageToMatrix((BufferedImage)car2); + car3P = imageToMatrix((BufferedImage)car3); + int x , y, z; + for(int i=0; i<200; i++){ + for(int j=0; j<150; j++){ + x = (int)((car1P[i][j]*3)/10); + y = (int)((car2P[i][j]*3)/10); + z = (int)((car3P[i][j]*3)/10); + if(x + y + z >255){ + imageP[i][j] = 255; + }else + imageP[i][j] = x + y + z; + } + } + + image = matrixToImage(imageN, imageP); + + + + } + + + +public Image getImage(){ + return image; +} + +public Image getcarImage(){ + return car1; +} +public Image getcar2Image(){ + return car2; +} +public Image getcar3Image(){ + return car3; +} + +} diff --git a/src/ImageConvolution.java b/src/ImageConvolution.java new file mode 100644 index 0000000..ecf1d5b --- /dev/null +++ b/src/ImageConvolution.java @@ -0,0 +1,155 @@ +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageConvolution extends OpenBB{ + + Image image,image2,image3,image4,image5, image6,image7,image8,image9,image10, + image11,image12,image13; + int[][] imageMatrix,imageMatrix2,imageMatrix3,imageMatrix4; + double[][] imageMatrixD,imageMatrix2D,imageMatrix3D, + imageMatrix4D,imageMatrix5D,imageMatrix6D,imageMatrix7D,imageMatrix8D, + imageMatrix9D,imageMatrix10D,imageMatrix11D,imageMatrix12D,imageMatrix13D; + double[][] a = {{0.1111111111,0.1111111111,0.1111111111}, + {0.1111111111,0.1111111111,0.1111111111}, + {0.1111111111,0.1111111111,0.1111111111}}; + double[][] b = {{0.05555555556,0.05555555556,0.05555555556}, + {0.05555555556,0.05555555556,0.05555555556}, + {0.05555555556,0.05555555556,0.05555555556}}; + double[][] c ={{-1,-1,-1}, + {-1, 9,-1}, + {-1,-1,-1}}; + double[][] d = {{0,-1, 0}, + {-1,5,-1}, + {0,-1, 0}}; + double[][] e = {{-1,0,1}, + {-1,0,1}, + {-1,0,1}}; + double[][] f = {{-1,-1,-1}, + {0,0,0}, + {1,1,1}}; + double[][] g = {{-1,-1,-1}, + { 0, 1, 0}, + { 1, 1, 1}}; + double[][] h = {{0.08333333333,0.08333333333,0.08333333333}, + {0.08333333333,0.3333333333 ,0.08333333333}, + {0.08333333333,0.08333333333,0.08333333333}}; + double[][] i = {{-1, 0, 0}, + { 0, 0, 0}, + { 0, 0, 1}}; + double[][] j = {{ 0, 0, -1}, + { 0, 0, 0}, + { 1, 0, 0}}; + double[][] k = {{ 0, 1, 0}, + { 0, 0, 0}, + { 0, -1, 0}}; + double[][] l = {{ 0, 0, 0}, + {-1, 0, 1}, + { 0, 0, 0}}; + + public ImageConvolution(){ + + try { + image = ImageIO.read(new File("images/house.jpg")); + imageMatrix = imageToMatrix((BufferedImage)image); + imageMatrix2D = convolve(imageMatrix,a); + image2 = matrixToImage("a", doubleToInt(imageMatrix2D)); + imageMatrix3D = convolve(imageMatrix,b); + image3 = matrixToImage("b", doubleToInt(imageMatrix3D)); + imageMatrix4D = convolve(imageMatrix,c); + image4 = matrixToImage("c", doubleToInt(imageMatrix4D)); + imageMatrix5D = convolve(imageMatrix,d); + image5 = matrixToImage("d", doubleToInt(imageMatrix5D)); + imageMatrix6D = convolve(imageMatrix,e); + image6 = matrixToImage("e", doubleToInt(imageMatrix6D)); + imageMatrix7D = convolve(imageMatrix,f); + image7 = matrixToImage("f", doubleToInt(imageMatrix7D)); + imageMatrix8D = convolve(imageMatrix,g); + image8 = matrixToImage("g", doubleToInt(imageMatrix8D)); + imageMatrix9D = convolve(imageMatrix,h); + image9 = matrixToImage("h", doubleToInt(imageMatrix9D)); + imageMatrix10D = convolve(imageMatrix,i); + image10 = matrixToImage("i", doubleToInt(imageMatrix10D)); + imageMatrix11D = convolve(imageMatrix,j); + image11 = matrixToImage("j", doubleToInt(imageMatrix11D)); + imageMatrix12D = convolve(imageMatrix,k); + image12 = matrixToImage("k", doubleToInt(imageMatrix12D)); + imageMatrix13D = convolve(imageMatrix,l); + image13 = matrixToImage("l", doubleToInt(imageMatrix13D)); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public Image getImage() { + // TODO Auto-generated method stub + return image; + } + + public Image getImage2() { + // TODO Auto-generated method stub + return image2; + } + + public Image getImage3() { + // TODO Auto-generated method stub + return image3; + } + + public Image getImage4() { + // TODO Auto-generated method stub + return image4; + } + + public Image getImage5() { + // TODO Auto-generated method stub + return image5; + } + + public Image getImage6() { + // TODO Auto-generated method stub + return image6; + } + public Image getImage7() { + // TODO Auto-generated method stub + return image7; + } + + public Image getImage8() { + // TODO Auto-generated method stub + return image8; + } + + public Image getImage9() { + // TODO Auto-generated method stub + return image9; + } + + public Image getImage10() { + // TODO Auto-generated method stub + return image10; + } + + public Image getImage11() { + // TODO Auto-generated method stub + return image11; + } + + public Image getImage12() { + // TODO Auto-generated method stub + return image12; + } + + public Image getImage13() { + // TODO Auto-generated method stub + return image13; + } + + + +} diff --git a/src/ImageCropFlip.java b/src/ImageCropFlip.java new file mode 100644 index 0000000..7567ce9 --- /dev/null +++ b/src/ImageCropFlip.java @@ -0,0 +1,106 @@ + +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageCropFlip extends OpenBB{ + + Image balloon,image,image2,image3,balloontemp; + int[][] balloonP,imageP,imageP2; + String imagePart,imagePart2,balloonPart; + + + public ImageCropFlip(){ + try { + imagePart = "balloon_part"; + imagePart2 = "balloon_part2"; + balloonPart= "balloon_part3"; + balloon = ImageIO.read(new File("images/balloon.bmp")); + balloonP = new int[500][360]; + imageP = new int[200][100]; + imageP2 = new int[500][360]; + balloonP = imageToMatrix((BufferedImage)balloon); + + for(int i=0; i<500; i++){ + for(int j=0; j<360; j++){ + if(i>=100 && j>=100 && i<300 && j<200){ + imageP[i-100][j-100] = balloonP[i][j]; + balloonP[i][j] = 0; + } + } + } + image2 = flipVer(imageP); + image3 = flipHor(imageP); + image = matrixToImage(imagePart, imageP); + balloon = matrixToImage(balloonPart,balloonP); + imageP2 = imageToMatrix((BufferedImage)image2); + int[][] temp = new int[500][360]; + for(int i=0; i<500;i++){ + for(int j=0; j< 360; j++){ + if(i>=100 && j>=100 && i<300 && j<200){ + balloonP[i][j] = imageP2[i-100][j-100]; + } + } + } + + balloontemp = matrixToImage("temp",balloonP); + + + + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + + +public Image getImage(){ + return image; +} +public Image getImage2(){ + return image2; +} +public Image getImage3(){ + return image3; +} +public Image getBalloon(){ + return balloon; +} +public Image getBalloonTemp(){ + return balloontemp; +} + +public Image flipVer(int[][] im){ + int[][] temp = new int[200][100]; + for(int i=0; i<200; i++){ + for(int j =0; j<100; j++){ + temp[i][j] = im[i][99-j]; + } + } + return matrixToImage("temp",temp); +} + +public Image flipHor(int[][] im){ + int[][] temp = new int[200][100]; + for(int i=0; i<200; i++){ + for(int j =0; j<100; j++){ + temp[i][j] = im[199-i][j]; + } + } + return matrixToImage("temp2",temp); +} + + + + +} diff --git a/src/ImageMasking.java b/src/ImageMasking.java new file mode 100644 index 0000000..aa3508f --- /dev/null +++ b/src/ImageMasking.java @@ -0,0 +1,152 @@ +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageMasking extends OpenBB{ + + private Image street,street2,street3,street4,street5; + //396*621 + private int[][] st,st2,st3,st4,st5; + //target 300*444 + + public ImageMasking(){ + + try { + street = ImageIO.read(new File("images/street.jpg")); + st = new int[396][621]; + st = imageToMatrix((BufferedImage)street); + st2 = new int[396][621]; + st3 = new int[396][621]; + st4 = new int[396][621]; + st5 = new int[396][621]; + street3 = drawCircle(290,445,50); + street2 = putMask(); + street4 = andIt(); + street5 = finilize(); + + + } catch (IOException e) { + + e.printStackTrace(); + } + + } + + private Image finilize() { + int[][] p = new int[396][621]; + int[][] p2 = new int[396][621]; + for(int i=0; i<396; i++){ + for(int j=0; j<621; j++){ + + p[i][j] = (int)(st[i][j]*0.8); + p2[i][j] = (int)(st4[i][j]*1.1); + if(st4[i][j]==0)st5[i][j]=p[i][j]; + else st5[i][j]=p2[i][j]; + } + } + + Image test = matrixToImage("test", st5); + return test; + } + + private Image andIt() { + //And st3 and st + for(int i=0; i<396; i++){ + for(int j=0; j<621; j++){ + + if(st3[i][j]==255) st4[i][j] = st[i][j]; + else + st4[i][j] = 0; + + } + } + street4 = matrixToImage("test", st4); + return street4; + } + + + + + + public Image putMask(){ + int[][] p = new int[396][621]; + for(int i=0; i<396; i++){ + for(int j=0; j<621; j++){ + if(st3[i][j]==1 || st3[i][j]==255) + st3[i][j]=255; + } + } + + for(int i=0; i<396; i++){ + for(int j=0; j<621; j++){ + if(st3[i][j]==0)p[i][j]=st[i][j]; + else if(st3[i][j]==255)p[i][j]=0; + } + } + + + return matrixToImage("test",p); + + + } + + public Image drawCircle(int x, int y, int r){ + int[][] p = new int[396][621]; + final double PI = 3.1415926535; + double angle, x1, y1; + + for(int i=0; i<396; i++){ + for(int j=0; j<621; j++){ + p[i][j] = 255; + } + } + + for(double i = 0; i < 360; i += 0.01){ + angle = i; + x1 = r * Math.cos(angle * PI / 180); + y1 = r * Math.sin(angle * PI / 180); + p[(int)(x+x1)][(int)(y+y1)] = 1; + } + for(int i=0; i<396; i++){ + for(int j=0; j<621; j++){ + if(p[i][j]==255)p[i][j]=0; + else + if(p[i][j]==1) j = 621; + + } + } + for(int i=390; i>=0; i--){ + for(int j=620; j>=0; j--){ + if(p[i][j]==255)p[i][j]=0; + else + if(p[i][j]==1) j = 0; + + } + } + st3 = p; + return matrixToImage("test",p); + } + + public Image getImage(){ + return street; + } + public Image getImage2(){ + return street2; + } + public Image getImage3(){ + return street3; + } + + public Image getImage4(){ + return street4; + } + + public Image getImage5(){ + return street5; + } + + +} diff --git a/src/ImageResize.java b/src/ImageResize.java new file mode 100644 index 0000000..9673e6a --- /dev/null +++ b/src/ImageResize.java @@ -0,0 +1,64 @@ + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageResize extends OpenBB{ + + + Image image6,image5, originalImage; + int[][] image5Pixels,image6Pixels; + String imageName; + + public ImageResize(){ + + init4(); + + } + + private void init4() { + try { + imageName = "P1_out2"; + originalImage = ImageIO.read(new File("images/Imbw.bmp")); + image5 = resizeImage((BufferedImage)originalImage, 100, 100); + image5Pixels = new int[100][100]; + image6Pixels = new int[400][400]; + image5Pixels = imageToMatrix((BufferedImage)image5); + for(int i=0; i<400; i++){ + for(int j=0; j<400; j++){ + image6Pixels[i][j] = image5Pixels[i%100][j%100]; + } + } + + image6 = matrixToImage(imageName, image6Pixels); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static BufferedImage resizeImage(BufferedImage originalImage,int w, int h){ + BufferedImage resizedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR); + Graphics2D g = resizedImage.createGraphics(); + g.drawImage(originalImage, 0, 0, w, h, null); + g.dispose(); + + return resizedImage; + } + + public Image getImage5(){ + return image5; + } + public Image getImage6(){ + return image6; + } + + + +} diff --git a/src/ImageRotation.java b/src/ImageRotation.java new file mode 100644 index 0000000..8c3b5f0 --- /dev/null +++ b/src/ImageRotation.java @@ -0,0 +1,70 @@ + +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageRotation extends OpenBB{ + + private Image cameraMan,cameraManR; + private int[][] camera,cameraP; + + public ImageRotation(){ + + try { + cameraMan = ImageIO.read(new File("images/cameraman.jpg")); + camera = new int[256][256]; + cameraP = new int[256][256]; + camera = imageToMatrix((BufferedImage)cameraMan); + rotate(45); + cameraManR = matrixToImage("camera_rotated_"+45, cameraP); + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void rotate(int theta) { + + int width = camera.length; + int height = camera[0].length; + //double radiant = (theta*Math.PI)/180; + + double sin = Math.sin(-theta); + double cos = Math.cos(-theta); + double x0 = width/2; + double y0 = height/2; + // rotation + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + double a = x - x0; + double b = y - y0; + + int xx = (int) (x0+(cos*a+sin*b)); + int yy = (int) (y0+(-sin*a+cos*b)); + + if (xx >= 0 && xx < width && yy >= 0 && yy < height) { + cameraP[x][y] = camera[xx][yy]; + }else + cameraP[x][y] = 0; + } + } + + + } + + + public Image getImage(){ + return cameraMan; + } + public Image getImageR(){ + return cameraManR; + } +} diff --git a/src/ImageShearing.java b/src/ImageShearing.java new file mode 100644 index 0000000..ee46084 --- /dev/null +++ b/src/ImageShearing.java @@ -0,0 +1,76 @@ + +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageShearing extends OpenBB{ + + private Image cameraMan,cameraManS; + private int[][] camera; + + public ImageShearing(){ + + try { + cameraMan = ImageIO.read(new File("images/cameraman.jpg")); + camera = new int[256][256]; + camera = imageToMatrix((BufferedImage)cameraMan); + cameraManS = shear(0.4,0.2,camera); + + + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + + + private Image shear(double xShear, double yShear, int[][] cam) { + + int width = cam.length; + int height = cam[0].length; + int[][] temp = new int[width][height]; + double x0 = width/2; + double y0 = height/2; + + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + double a = x - x0; + double b = y - y0; + + int xx = (int) (a+b*xShear+x0); + int yy = (int) (a*yShear+b+y0); + + if (xx >= 0 && xx < width && yy >= 0 && yy < height) { + temp[x][y] = cam[xx][yy]; + }else + temp[x][y] = 0; + } + } + + + Image img = matrixToImage("cameraman_shear",temp); + + + + return img; + } + + public Image getImage(){ + return cameraMan; + } + + public Image getImageS(){ + return cameraManS; + } + +} diff --git a/src/ImageSteganography.java b/src/ImageSteganography.java new file mode 100644 index 0000000..7633890 --- /dev/null +++ b/src/ImageSteganography.java @@ -0,0 +1,50 @@ +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageSteganography extends OpenBB{ + + + BufferedImage image,image2,image3,image4,image5,image6; + + public ImageSteganography(){ + + try { + image = ImageIO.read(new File("images/lena.jpg")); + image2 = ImageIO.read(new File("images/barbara.jpg")); + image3 = hide(image, image2,1); + image4 = hide(image, image2,2); + image5 = hide(image, image2,3); + image6 = reveal(image5, 3); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + public Image getImage(){ + return image; + } + public Image getImage2(){ + return image2; + } + public Image getImage3(){ + return image3; + } + public Image getImage4(){ + return image4; + } + public Image getImage5(){ + return image5; + } + public Image getImage6(){ + return image6; + } + + +} diff --git a/src/ImageStitching.java b/src/ImageStitching.java new file mode 100644 index 0000000..5bf8441 --- /dev/null +++ b/src/ImageStitching.java @@ -0,0 +1,107 @@ + +import java.awt.Color; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.image.Raster; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageStitching extends OpenBB{ + + private Image input1,input2,output; + private int[][] inp1,inp2,out; + + public ImageStitching(){ + + try { + int m = 0; + input1 = ImageIO.read(new File("images/input1.jpg")); + input2 = ImageIO.read(new File("images/input2.jpg")); + inp1 = new int[400][357]; + inp2 = new int[400][357]; + + inp1 = imageToMatrix((BufferedImage)input1); + inp2 = imageToMatrix((BufferedImage)input2); + int[] l1 = new int[357]; + int[] l2 = new int[357]; + boolean b = false; + + for(int i=0; i<400; i++){ + + for(int k =0; k<357; k++) + l1[k] = inp1[i][k]; + + for(int j =0; j<400; j++){ + for(int k=0; k<357; k++){ + l2[k] = inp2[j][k]; + } + if(equalsTo(l1, l2)){ + System.out.print("("+i+","+j+")"+equalsTo(l1, l2)+"-\n"); + b = false; + + } + + if(!b && m==0){ + m = i; + b = true; + } + } + + + } + out = new int[m+400][357]; + for(int i=0; i<400+m; i++){ + for(int j=0; j<357; j++){ + + if(im && i<400){ + if(inp1[i][j]+inp2[i-m][j]>255){ + out[i][j] = 255; + }else + out[i][j] = inp1[i][j]+inp2[i-m][j]; + }else{ + out[i][j] = inp2[i-m][j]; + } + } + + } + } + + output = matrixToImage("P9_out1",out); + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + + public Image getImageI1(){ + return input1; + } + public Image getImageI2(){ + return input2; + } + + public Image getImageO(){ + return output; + } + + public boolean equalsTo(int[] l1, int[] l2){ + + for(int i=0; i> 16) & 0xFF; + int g = (rgb >> 8) & 0xFF; + int b = (rgb & 0xFF); + + int grayLevel = (r + g + b) / 3; + int gray = (grayLevel << 16) + (grayLevel << 8) + grayLevel; + img.setRGB(x, y, gray); + } + + saveFile(name,img); + + + return img; + } + + public void saveFile(String name, BufferedImage img){ + File output=new File("images/"+name+".bmp"); + try { + ImageIO.write(img,"bmp",output); + }catch (Exception e){ + e.printStackTrace(); + } + } + + public BufferedImage matrixToImage(String name,int[][] gray){ + //BufferedImage.TYPE_BYTE_GRAY = BufferedImage.TYPE_INT_RGB + makeGray(); + int w=gray.length; + int h=gray[0].length; + BufferedImage image=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); + for (int i = 0; i < w; i++) { + for (int j = 0; j < h; j++) { + Color c = new Color(gray[i][j], gray[i][j], gray[i][j]); + image.setRGB(i, j, c.getRGB()); + } + } + makeGray(name,image); + return image; + + } + + public void showMatrix(double[][] mat){ + for(int i=0; i=0; i--) + if(numbers[i]=='1') + result += Math.pow(2, (numbers.length-i - 1)); + return result; + } + + public String ANDBinaries(String s1, String s2) { + String a = null; + System.out.println(s1+"/"+s2); + for(int i=0; i0; i--) + if(his1[i]>100){ + c = i-1; + } + for(int i=0; i<255; i++) + if(his1[i]>100){ + d = i+1; + } + + + int w = imageMatrix.length; + int h = imageMatrix[0].length; + int[][] im = new int[w][h]; + for(int i=0; i255)im[i][j] = 255; + if(im[i][j]<0)im[i][j] = 0; + } + } + c_hs = c; + d_hs = d; + return im; + } + public int getcc(){ + return c_hs; + } + public int getdd(){ + return d_hs; + } + + public int[][] multCToImagePixels(int[][] ip, double c){ + int[][] ip2 = new int[ip.length][ip[0].length]; + for(int i=0; i255) ip2[i][j]=255; + if(ip2[i][j]<0) ip2[i][j]=0; + } + } + return ip2; + } + + public int[][] logNormalization(int[][] ip, double c){ + int[][] ip2 = new int[ip.length][ip[0].length]; + for(int i=0; i255)ip2[i][j] = 255; + if(ip2[i][j]<0)ip2[i][j] = 0; + } + } + + return ip2; + } + + public int[][] powerLaw(int[][] ip, double c,double gamma){ + int[][] ip2 = new int[ip.length][ip[0].length]; + for(int i=0; i255)ip2[i][j] = 255; + if(ip2[i][j]<0)ip2[i][j] = 0; + } + } + + return ip2; + } + + + public double[][] equalize(int[][] src, int max){ + double[][] ip = new double[max][5]; + double sum, total; + total = src.length* src[0].length; + for(int p = 0; p=0; j--){ + sum += ip[j][1]; + } + ip[i][2] = sum; + } + + for(int i=0; i0;j--){ + if(t3[i][0]<=t3[j][1]){ + t3[i][2] = j; + } + } + } + int[][] output = src; + for(int i=0; i> 16) & 0xff); + green += ((pixel >> 8 ) & 0xff); + blue += ((pixel) & 0xff); + } + } + //average is computed using integer arithmetic. If the box size is too large + //this routine will fail. max box size = (INT_Max/256) = 8,388,608 + red /= boxSize; + green /= boxSize; + blue /= boxSize; + //returns the reconstructed pixel back + return (alpha | (red << 16) | (green << 8 ) | blue); + } + + public double[][] intToDouble(int[][] in){ + double[][] out = new double[in.length][in[0].length]; + for(int i=0; i255)out[i][j]=255; + } + } + + return out; + } + + + public double[][] convolve(int[][] in, double[][] k){ + double[][] out = new double[in.length][in[0].length]; + double sum; + int zeroi,zeroj; + for(int i=0; i255)out[i][j] = 255; + if(out[i][j]<0)out[i][j] = 0; + } + } + } + } + return out; + } + + // Hide the first i MSB of pixelB in pixelA + private int hidePixel(int pixelA, int pixelB, int i) { + return pixelA & 0xFFF8F8F8 | (pixelB & 0x00E0E0E0) >> (8-i); + } + + // Extract the last i LSB + private int revealPixel(int pixel, int i) { + return (pixel & 0xFF070707) << (8-i); + } + + // Hide hiddenImage into coverImage + public BufferedImage hide(BufferedImage imageSource, BufferedImage imageToHide, int k) { + int width = imageSource.getWidth(); + int height = imageSource.getHeight(); + BufferedImage imageResult = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + imageResult.setRGB(i, j, hidePixel(imageSource.getRGB(i, j), imageToHide.getRGB(i, j),k)); + } + } + + return imageResult; + } + + // Reveal hidden image into resultImage + public BufferedImage reveal(BufferedImage imageSource, int k) { + BufferedImage imageResult = new BufferedImage(512, 512, BufferedImage.TYPE_BYTE_GRAY); + int width = imageResult.getWidth(); + int height = imageResult.getHeight(); + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + imageResult.setRGB(i, j, revealPixel(imageSource.getRGB(i, j),k)); + } + } + return imageResult; + } + + // Additional methods from CG1 OpenBB + public BufferedImage createImage(String name, int[][] red, int[][] green, int[][] blue){ + int w=red.length; + int h=red[0].length; + BufferedImage image=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); + for (int i = 0; i < w; i++) { + for (int j = 0; j < h; j++) { + Color c = new Color(red[i][j], green[i][j], blue[i][j]); + image.setRGB(i, j, c.getRGB()); + } + } + makeGray(name,image); + return image; + } + +} + diff --git a/src/Screen.java b/src/Screen.java new file mode 100644 index 0000000..ec01fa0 --- /dev/null +++ b/src/Screen.java @@ -0,0 +1,628 @@ +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +public class Screen extends JPanel{ + + JScrollPane scrollPane; + final int clear = 44; + + public Screen(){ + JFrame jframe = new JFrame(); + JMenuBar menuBar = new JMenuBar(); + JMenu menu = new JMenu("Homeworks"); + JMenu menu1 = new JMenu("Homework 1"); + JMenu menu2 = new JMenu("Homework 2"); + JMenu menu3 = new JMenu("Homework 3"); + JMenu menu4 = new JMenu("Homework 4"); + JMenu menu5 = new JMenu("Homework 5"); + JMenu menu6 = new JMenu("Homework 6"); + JMenu menu7 = new JMenu("Homework 7"); + JMenu menu8 = new JMenu("Homework 8"); + JMenu menu9 = new JMenu("Homework 9"); + JMenu menu10 = new JMenu("Homework 10"); + JMenuItem hw1mI1 = new JMenuItem("part 1"); + JMenuItem hw1mI2 = new JMenuItem("part 2"); + JMenuItem hw1mI3 = new JMenuItem("part 3"); + JMenuItem hw1mI4 = new JMenuItem("part 4"); + JMenuItem hw2mI1 = new JMenuItem("part 1"); + JMenuItem hw2mI2 = new JMenuItem("part 2"); + JMenuItem hw2mI3 = new JMenuItem("part 3"); + JMenuItem hw3mI1 = new JMenuItem("part 1"); + JMenuItem hw4mI1 = new JMenuItem("part 1"); + JMenuItem hw5mI1 = new JMenuItem("part 1"); + JMenuItem hw6mI1 = new JMenuItem("part 1"); + JMenuItem hw7mI1 = new JMenuItem("part 1"); + JMenuItem hw8mI1 = new JMenuItem("part 1"); + JMenuItem hw9mI1 = new JMenuItem("part 1"); + JMenuItem hw10mI1 = new JMenuItem("part 1"); + menu1.add(hw1mI1); + menu1.add(hw1mI2); + menu1.add(hw1mI3); + menu1.add(hw1mI4); + menu2.add(hw2mI1); + menu2.add(hw2mI2); + menu2.add(hw2mI3); + menu3.add(hw3mI1); + menu4.add(hw4mI1); + menu5.add(hw5mI1); + menu6.add(hw6mI1); + menu7.add(hw7mI1); + menu8.add(hw8mI1); + menu9.add(hw9mI1); + menu10.add(hw10mI1); + menu.add(menu1); + menu.add(menu2); + menu.add(menu3); + menu.add(menu4); + menu.add(menu5); + menu.add(menu6); + menu.add(menu7); + menu.add(menu8); + menu.add(menu9); + menu.add(menu10); + + // CG2 menus + JMenu menu11 = new JMenu("Binary Thresholding"); + JMenu menu12 = new JMenu("Histogram Stretching"); + JMenu menu13 = new JMenu("Histogram Equalization"); + JMenu menu14 = new JMenu("Histogram Matching"); + JMenu menu15 = new JMenu("Unsharp Masking"); + JMenu menu16 = new JMenu("Image Convolution"); + JMenu menu17 = new JMenu("Image Steganography"); + + JMenuItem hw11mI1 = new JMenuItem("part 1"); + JMenuItem hw11mI2 = new JMenuItem("part 2"); + JMenuItem hw12mI1 = new JMenuItem("part 1"); + JMenuItem hw12mI2 = new JMenuItem("part 2"); + JMenuItem hw12mI3 = new JMenuItem("part 3"); + JMenuItem hw13mI1 = new JMenuItem("part 1"); + JMenuItem hw13mI2 = new JMenuItem("part 2"); + JMenuItem hw14mI1 = new JMenuItem("part 1"); + JMenuItem hw14mI2 = new JMenuItem("part 2"); + JMenuItem hw15mI1 = new JMenuItem("part 1"); + JMenuItem hw16mI1 = new JMenuItem("part 1"); + JMenuItem hw16mI2 = new JMenuItem("part 2"); + JMenuItem hw16mI3 = new JMenuItem("part 3"); + JMenuItem hw17mI1 = new JMenuItem("part 1"); + + menu11.add(hw11mI1); + menu11.add(hw11mI2); + menu12.add(hw12mI1); + menu12.add(hw12mI2); + menu12.add(hw12mI3); + menu13.add(hw13mI1); + menu13.add(hw13mI2); + menu14.add(hw14mI1); + menu14.add(hw14mI2); + menu15.add(hw15mI1); + menu16.add(hw16mI1); + menu16.add(hw16mI2); + menu16.add(hw16mI3); + menu17.add(hw17mI1); + + menu.add(menu11); + menu.add(menu12); + menu.add(menu13); + menu.add(menu14); + menu.add(menu15); + menu.add(menu16); + menu.add(menu17); + + menuBar.add(menu); + jframe.setJMenuBar(menuBar); + jframe.setTitle("CG_Unified_By_Saeed_Khosravi"); + jframe.setLocation(100, 150); + jframe.setSize(new Dimension(1100, 600)); + jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jframe.setVisible(true); + jframe.setResizable(false); + + Graphics g = jframe.getGraphics(); + hw1mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + CheckerboardImageGenerator hw = new CheckerboardImageGenerator(); + jframe.setTitle("hw1_A"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage(),100,100,jframe); + g.drawImage(hw.getImage2(),600,100,jframe); + + } + }); + hw1mI2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + jframe.setTitle("hw1_B"); + new CheckerboardImageGenerator(); + ImageAdditionInversion hw = new ImageAdditionInversion(); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage3(),100,100,jframe); + g.drawImage(hw.getImage4(),600,100,jframe); + + } + }); + + hw1mI3.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + new CheckerboardImageGenerator(); + jframe.setTitle("hw1_C"); + g.clearRect(0, clear, 1200, 600); + //resize hw.getImage2(); to 100*100; + ImageResize hw1C = new ImageResize(); + g.drawImage(hw1C.getImage6(),350,100,jframe); + + } + }); + + hw1mI4.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + jframe.setTitle("hw1_D"); + g.clearRect(0, clear, 1200, 600); + ImageSubtraction hw = new ImageSubtraction(); + g.drawImage(hw.getImage6(),350,100,jframe); + + } + }); + + + hw2mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + double c; + c = 100; + BrightnessContrastAdjustment hw = new BrightnessContrastAdjustment(c,1); + jframe.setTitle("hw2_A"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getOriginalImage(), 300, 100, jframe); + g.drawImage(hw.getImage(),600,100,jframe); + + } + }); + + hw2mI2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + + jframe.setTitle("hw2_B"); + g.clearRect(0, clear, 1200, 600); + ImageBlending hw = new ImageBlending(); + g.drawImage(hw.getcarImage(),100,50,jframe); + g.drawImage(hw.getcar2Image(),100,225,jframe); + g.drawImage(hw.getcar3Image(),100,400,jframe); + g.drawImage(hw.getImage(), 600, 225, jframe); + } + }); + + hw2mI3.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + double c; + c = 1.5; + BrightnessContrastAdjustment hw = new BrightnessContrastAdjustment(c,2); + jframe.setTitle("hw2_C"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getOriginalImage(), 300, 100, jframe); + g.drawImage(hw.getImage(),600,100,jframe); + + } + }); + + hw3mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ImageCropFlip hw = new ImageCropFlip(); + jframe.setTitle("hw3"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getBalloon(), 10, 60, jframe); + g.drawImage(hw.getImage(),10,450,jframe); + g.drawImage(hw.getImage2(),250,450,jframe); + g.drawImage(hw.getImage3(),490,450,jframe); + g.drawImage(hw.getBalloonTemp(),550,60,jframe); + } + }); + + hw4mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + GrayScalePattern hw = new GrayScalePattern(); + jframe.setTitle("hw4"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage(), 400, 150, jframe); + } + }); + + hw5mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + BitPlaneSlicing hw = new BitPlaneSlicing(); + jframe.setTitle("hw5"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage(8), 10, 60, 220,200, jframe); + g.drawImage(hw.getImage(7), 240, 60, 220,200, jframe); + g.drawImage(hw.getImage(6), 470, 60, 220,200, jframe); + g.drawImage(hw.getImage(5), 700, 60, 220,200, jframe); + g.drawImage(hw.getImage(4), 10, 300, 220,200, jframe); + g.drawImage(hw.getImage(3), 240, 300, 220,200, jframe); + g.drawImage(hw.getImage(2), 470, 300, 220,200, jframe); + g.drawImage(hw.getImage(1), 700, 300, 220,200, jframe); + + } + }); + + hw6mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + BlockAveraging hw = new BlockAveraging(); + jframe.setTitle("hw6"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage(1), 10, 60, 220,200, jframe); + g.drawImage(hw.getImage(2), 240, 60, 220,200, jframe); + g.drawImage(hw.getImage(3), 470, 60, 220,200, jframe); + g.drawImage(hw.getImage(4), 700, 60, 220,200, jframe); + } + }); + hw7mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ImageRotation hw = new ImageRotation(); + jframe.setTitle("hw7"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage(),250,100,jframe); + g.drawImage(hw.getImageR(),550,100,jframe); + + } + }); + + hw8mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ImageShearing hw = new ImageShearing(); + jframe.setTitle("hw8"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage(),250,100,jframe); + g.drawImage(hw.getImageS(),550,100,jframe); + + } + }); + hw9mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ImageStitching hw = new ImageStitching(); + jframe.setTitle("hw9"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImageI1(),100,50,324,270,jframe); + g.drawImage(hw.getImageI2(),100,325,324,270,jframe); + g.drawImage(hw.getImageO(),440,160,jframe); + + + } + }); + hw10mI1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ImageMasking hw = new ImageMasking(); + jframe.setTitle("hw10"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage(),10,50,198,310,jframe); + g.drawImage(hw.getImage2(),210,50,198,310,jframe); + g.drawImage(hw.getImage3(),410,50,198,310,jframe); + g.drawImage(hw.getImage4(),610,50,198,310,jframe); + g.drawImage(hw.getImage5(),810,50,198,310,jframe); + + + } + }); + + // CG2 action listeners + hw11mI1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + BinaryThresholding hw = new BinaryThresholding(); + jframe.setTitle("Binary Thresholding"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage(),100,100,450,250,jframe); + new Histogram(hw.getImageHistogram(),jframe.getGraphics(), 450, 590, 230); + g.drawImage(hw.getImage2(),560,100,450,250,jframe); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw11mI2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + BinaryThresholding hw = new BinaryThresholding(); + jframe.setTitle("Binary Thresholding"); + g.clearRect(0, clear, 1200, 600); + g.drawImage(hw.getImage3(),100,100,450,250,jframe); + new Histogram(hw.getImageHistogram2(),jframe.getGraphics(), 450, 590, 230); + g.drawImage(hw.getImage4(),560,100,450,250,jframe); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw12mI1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + HistogramStretching hw = new HistogramStretching(); + jframe.setTitle("Histogram Stretching"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("Original Image", 110, 65); + g.drawImage(hw.getImage(),100,70,jframe); + new Histogram(hw.getImageHistogram(),jframe.getGraphics(), 100, 590, 230); + g.drawString("Histogram Strech [c = "+hw.getc()+",d = "+hw.getd()+"]", 410, 65); + g.drawImage(hw.getImage2(),400,70,jframe); + new Histogram(hw.getImageHistogram2(),jframe.getGraphics(), 400, 590, 230); + g.drawString("Scaling by C = "+hw.getC(), 710, 65); + g.drawImage(hw.getImage3(),700,70,jframe); + new Histogram(hw.getImageHistogram3(),jframe.getGraphics(), 700, 590, 230); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw12mI2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + HistogramStretching hw = new HistogramStretching(); + jframe.setTitle("Histogram Stretching"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("Original Image", 110, 65); + g.drawImage(hw.getImage4(),100,70,jframe); + new Histogram(hw.getImageHistogram4(),jframe.getGraphics(), 100, 590, 230); + g.drawString("Log Normalization with C = "+hw.getC(), 410, 65); + g.drawImage(hw.getImage5(),400,70,jframe); + new Histogram(hw.getImageHistogram5(),jframe.getGraphics(), 400, 590, 230); + g.drawString("P_Law Normalization C = "+hw.getC()+", Gamma = "+hw.getGamma(), 710, 65); + g.drawImage(hw.getImage6(),700,70,jframe); + new Histogram(hw.getImageHistogram6(),jframe.getGraphics(), 700, 590, 230); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw12mI3.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + HistogramStretching hw = new HistogramStretching(); + jframe.setTitle("Histogram Stretching"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("Original Image", 110, 65); + g.drawImage(hw.getImage7(),100,70,326,200,jframe); + new Histogram(hw.getImageHistogram7(),jframe.getGraphics(), 100, 590, 230); + g.drawString("Log Normalization with C = "+hw.getC(), 440, 65); + g.drawImage(hw.getImage8(),430,70,326,200,jframe); + new Histogram(hw.getImageHistogram8(),jframe.getGraphics(), 430, 590, 230); + g.drawString("P_Law Normalization C = "+hw.getC()+", Gamma = "+hw.getGamma(), 770, 65); + g.drawImage(hw.getImage9(),760,70,326,200,jframe); + new Histogram(hw.getImageHistogram9(),jframe.getGraphics(), 760, 590, 230); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw13mI1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + HistogramEqualization hw = new HistogramEqualization(); + jframe.setTitle("Histogram Equalization"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("Original Image", 110, 65); + g.drawImage(hw.getImage(),100,70,200,200,jframe); + new Histogram(hw.getImageHistogram(),jframe.getGraphics(), 100, 590, 230); + Object columns[] = { "f", "P(I)", "g - sigma(P(I))","g*max","PG" }; + JTable table = new JTable(hw.getTable(), columns); + scrollPane = new JScrollPane(table); + jframe.add(scrollPane, BorderLayout.EAST); + jframe.setVisible(true); + g.drawString("Histogram Equalization", 370, 65); + g.drawImage(hw.getImage2(),360,70,200,200,jframe); + new Histogram(hw.getImageHistogram2(),jframe.getGraphics(), 360, 590, 230); + } + }); + + hw13mI2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + HistogramEqualization hw = new HistogramEqualization(); + jframe.setTitle("Histogram Equalization"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("Original Image", 110, 65); + g.drawImage(hw.getImage3(),100,70,jframe); + new Histogram(hw.getImageHistogram3(),jframe.getGraphics(), 100, 590, 230); + g.drawString("Histogram Equalization", 510, 65); + g.drawImage(hw.getImage4(),500,70,jframe); + new Histogram(hw.getImageHistogram4(),jframe.getGraphics(), 500, 590, 230); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw14mI1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + HistogramMatching hw = new HistogramMatching(); + jframe.setTitle("Histogram Matching"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("Original Image", 110, 65); + g.drawImage(hw.getImage(),100,70,380,280,jframe); + new Histogram(hw.getHistogram(),jframe.getGraphics(), 100, 590, 230); + g.drawString("Histogram Equalization", 510, 65); + g.drawImage(hw.getImage2(),500,70,380,280,jframe); + new Histogram(hw.getHistogram2(),jframe.getGraphics(), 500, 590, 230); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw14mI2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + HistogramMatching hw = new HistogramMatching(); + jframe.setTitle("Histogram Matching"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("Pigeon Image", 20, 65); + g.drawImage(hw.getImage3(),10,70,350,250,jframe); + new Histogram(hw.getHistogram3(),jframe.getGraphics(), 10, 590, 230); + g.drawString("Soldier Image", 380, 65); + g.drawImage(hw.getImage4(),370,70,350,250,jframe); + new Histogram(hw.getHistogram4(),jframe.getGraphics(), 370, 590, 230); + g.drawString("Pigeon HM from Soldier H", 740, 65); + g.drawImage(hw.getImage5(),730,70,350,250,jframe); + new Histogram(hw.getHistogram5(),jframe.getGraphics(), 730, 590, 230); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw15mI1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + UnsharpMasking hw = new UnsharpMasking(); + jframe.setTitle("Unsharp Masking"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("house Image", 20, 65); + g.drawImage(hw.getImage(),10,70,350,250,jframe); + g.drawString("blured house Image", 380, 65); + g.drawImage(hw.getImage2(),370,70,350,250,jframe); + g.drawString("house minus blured Image", 740, 65); + g.drawImage(hw.getImage3(),730,70,350,250,jframe); + g.drawString("unsharp masking Image", 20, 340); + g.drawImage(hw.getImage4(),10,350,350,250,jframe); + g.drawString("Unsharped image using blured image by convolution concept. ", 370, 350); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw16mI1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ImageConvolution hw = new ImageConvolution(); + jframe.setTitle("Image Convolution"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("house Image", 20, 60); + g.drawImage(hw.getImage(),10,65,350,250,jframe); + g.drawString("a kernel", 380, 60); + g.drawImage(hw.getImage2(),370,65,350,250,jframe); + g.drawString("b kernel", 740, 60); + g.drawImage(hw.getImage3(),730,65,350,250,jframe); + g.drawString("c kernel", 20, 335); + g.drawImage(hw.getImage4(),10,340,350,250,jframe); + g.drawString("d kernel", 380, 335); + g.drawImage(hw.getImage5(),370,340,350,250,jframe); + g.drawString("e kernel", 740, 335); + g.drawImage(hw.getImage6(),730,340,350,250,jframe); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw16mI2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ImageConvolution hw = new ImageConvolution(); + jframe.setTitle("Image Convolution"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("f kernel", 20, 60); + g.drawImage(hw.getImage7(),10,65,350,250,jframe); + g.drawString("g kernel", 380, 60); + g.drawImage(hw.getImage8(),370,65,350,250,jframe); + g.drawString("h kernel", 740, 60); + g.drawImage(hw.getImage9(),730,65,350,250,jframe); + g.drawString("i kernel", 20, 335); + g.drawImage(hw.getImage10(),10,340,350,250,jframe); + g.drawString("j kernel", 380, 335); + g.drawImage(hw.getImage11(),370,340,350,250,jframe); + g.drawString("k kernel", 740, 335); + g.drawImage(hw.getImage12(),730,340,350,250,jframe); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw16mI3.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ImageConvolution hw = new ImageConvolution(); + jframe.setTitle("Image Convolution"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("l kernel", 20, 60); + g.drawImage(hw.getImage13(),10,65,350,250,jframe); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + hw17mI1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ImageSteganography hw = new ImageSteganography(); + jframe.setTitle("Image Steganography"); + g.clearRect(0, clear, 1200, 600); + g.setFont(new Font("Serif", Font.BOLD, 16)); + g.drawString("Cover Image", 20, 60); + g.drawImage(hw.getImage(),10,65,350,250,jframe); + g.drawString("Message Image", 380, 60); + g.drawImage(hw.getImage2(),370,65,350,250,jframe); + g.drawString("Message MSB 1", 740, 60); + g.drawImage(hw.getImage3(),730,65,350,250,jframe); + g.drawString("Message MSB 2", 20, 335); + g.drawImage(hw.getImage4(),10,340,350,250,jframe); + g.drawString("Message MSB 3", 380, 335); + g.drawImage(hw.getImage5(),370,340,350,250,jframe); + g.drawString("Reveal Image", 740, 335); + g.drawImage(hw.getImage6(),730,340,350,250,jframe); + if(scrollPane!= null) + jframe.remove(scrollPane); + } + }); + + } + +} diff --git a/src/UnsharpMasking.java b/src/UnsharpMasking.java new file mode 100644 index 0000000..5b73721 --- /dev/null +++ b/src/UnsharpMasking.java @@ -0,0 +1,69 @@ +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class UnsharpMasking extends OpenBB { + + Image image,image2,image3,image4; + int[][] imageMatrix,imageMatrix2,imageMatrix3,imageMatrix4; + double[][] imageMatrixD,imageMatrix2D,imageMatrix3D,imageMatrix4D; + double[][] kernel = {{0.1111111111,0.1111111111,0.1111111111}, + {0.1111111111,0.1111111111,0.1111111111}, + {0.1111111111,0.1111111111,0.1111111111}}; + public UnsharpMasking(){ + + try { + image = ImageIO.read(new File("images/house.jpg")); + imageMatrix = imageToMatrix((BufferedImage)image); + imageMatrix2D = convolve(imageMatrix,kernel); + image2 = matrixToImage("blured", doubleToInt(imageMatrix2D)); + //showMatrix(intToDouble(imageMatrix2)); + imageMatrixD = intToDouble(imageMatrix); + imageMatrix3D = imageMatrix2D; + for(int i=0; i255)imageMatrix4D[i][j]=255; + } + } + imageMatrix3 = doubleToInt(imageMatrix3D); + imageMatrix4 = doubleToInt(imageMatrix4D); + image3 = matrixToImage("hw5_1", imageMatrix3); + image4 = matrixToImage("hw5_2", imageMatrix4); + + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + public Image getImage(){ + return image; + } + public Image getImage2(){ + return image2; + } + public Image getImage3(){ + return image3; + } + public Image getImage4(){ + return image4; + } +}