├── .classpath
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
└── org.eclipse.jdt.core.prefs
├── bin
└── com
│ └── book
│ ├── chapter
│ ├── eight
│ │ ├── BilateralFilter.class
│ │ ├── BlurFilter.class
│ │ ├── BoxBlurFilter.class
│ │ ├── ConvolutionFilter.class
│ │ ├── GaussianBlurFilter.class
│ │ ├── LaplacianSharpenFilter.class
│ │ ├── PixellateFilter.class
│ │ ├── SmoothFilter.class
│ │ ├── StatisticsFilter.class
│ │ ├── moon.png
│ │ └── noiselena.png
│ ├── eleven
│ │ ├── A-Set.png
│ │ ├── B-Set.png
│ │ ├── BoundaryExtractionFilter.class
│ │ ├── CloseFilter.class
│ │ ├── DilationFilter.class
│ │ ├── DistanceTransform.class
│ │ ├── ErosionFilter.class
│ │ ├── FIFOQueue.class
│ │ ├── GrayDilationFilter.class
│ │ ├── GrayErosionFilter.class
│ │ ├── HitAndMissFilter.class
│ │ ├── OpenFilter.class
│ │ ├── PixelPoint.class
│ │ ├── SetOperatorFilter.class
│ │ ├── WatershedTransform.class
│ │ ├── close.png
│ │ ├── open.png
│ │ ├── person.png
│ │ └── watershed_test.png
│ ├── five
│ │ ├── BitBltFilter.class
│ │ ├── BitBltFilterTest.class
│ │ ├── BlendFilter.class
│ │ ├── NatureFilter.class
│ │ ├── PMMDFilter.class
│ │ └── rainbow.png
│ ├── four
│ │ ├── AbstractBufferedImageOp.class
│ │ ├── BCSAdjustFilter.class
│ │ ├── BrightContrastSatUI.class
│ │ ├── BrightFilter.class
│ │ ├── ContrastFilter.class
│ │ ├── SaturationFilter.class
│ │ └── SepiaToneFilter.class
│ ├── fourteen
│ │ ├── MainUI$1.class
│ │ ├── MainUI.class
│ │ ├── MomentsUtil.class
│ │ ├── ScaleFilter.class
│ │ ├── StrokeAreaFilter.class
│ │ ├── StrokeElement.class
│ │ ├── StrokeGenerator.class
│ │ ├── StrokePaintlyMain.class
│ │ ├── rainbow-fish-md.png
│ │ └── stroke.png
│ ├── nine
│ │ ├── CannyEdgeFilter.class
│ │ ├── GradientEdgeFilter.class
│ │ ├── LaplacianFilter.class
│ │ ├── RobotFilter.class
│ │ ├── SobolPrewittEdgeDetector.class
│ │ └── cameraman.png
│ ├── one
│ │ ├── AMERSN.ttf
│ │ ├── CustomJPanel.class
│ │ ├── FontDemo.class
│ │ ├── GeneralPathDemo.class
│ │ ├── JAVA2DDemo.class
│ │ ├── StrokeDemo.class
│ │ ├── TaijiDemo.class
│ │ └── lena.jpg
│ ├── seven
│ │ ├── BiLineRotateFilter.class
│ │ ├── BicubicSharpenFilter.class
│ │ ├── BicubicZoomFilter.class
│ │ ├── BilinearZoomFilter.class
│ │ ├── FastRotateFilter.class
│ │ ├── LanczosZoomFilter.class
│ │ ├── NearestZoomFilter.class
│ │ ├── XShearFilter.class
│ │ ├── YShearFilter.class
│ │ └── ZoomFilter.class
│ ├── six
│ │ ├── BinaryFilter.class
│ │ ├── HistogramComparisonFilter.class
│ │ ├── HistogramDataExtractor.class
│ │ ├── HistogramEFilter.class
│ │ ├── HistogramFilter.class
│ │ ├── HistogramPanel.class
│ │ ├── PixelStatisticFilter.class
│ │ ├── RGBHistogramFilter.class
│ │ ├── RedLineMonitor.class
│ │ ├── ViewCallBack.class
│ │ ├── blank.jpg
│ │ ├── emd
│ │ │ ├── Edge.class
│ │ │ ├── Edge0.class
│ │ │ ├── Edge1.class
│ │ │ ├── Edge2.class
│ │ │ ├── Edge3.class
│ │ │ ├── Feature.class
│ │ │ ├── Feature2D.class
│ │ │ ├── JFastEMD.class
│ │ │ ├── MinCostFlow.class
│ │ │ ├── Signature.class
│ │ │ └── Test.class
│ │ └── lena_gray.png
│ ├── ten
│ │ ├── AreaCenterFilter.class
│ │ ├── AreaOrientationFilter.class
│ │ ├── BFSAlgorithm.class
│ │ ├── BinaryDitherFilter.class
│ │ ├── BinaryEdgeFilter.class
│ │ ├── DFSAlgorithm.class
│ │ ├── FloodFillAlgorithm.class
│ │ ├── FloodFillUI.class
│ │ ├── GeometricMomentsAlg.class
│ │ ├── HalftoneFilter.class
│ │ ├── LabelledConnectedRegionAlg.class
│ │ ├── MooreNeighbourTraceAlgorithm.class
│ │ ├── MyQueue.class
│ │ ├── MyStack.class
│ │ ├── PixelPoint.class
│ │ ├── SquareTraceAlgorithm.class
│ │ ├── ThinPixel.class
│ │ ├── ZhangSuenThinningAlg.class
│ │ ├── area-angle.png
│ │ ├── binaryobject.png
│ │ ├── brain.png
│ │ ├── connectedcomponents.png
│ │ └── tools.png
│ ├── thirteen
│ │ ├── CircleHough.class
│ │ ├── CoOccurrenceMatrixFilter.class
│ │ ├── ColorFeatureExtractor.class
│ │ ├── GaussianDerivativeFilter.class
│ │ ├── GaussianFilter.class
│ │ ├── GrayFilter.class
│ │ ├── HarrisCornerDetector.class
│ │ ├── HarrisMatrix.class
│ │ ├── HoughFilter.class
│ │ ├── LineHough.class
│ │ ├── PyramidAlgorithm.class
│ │ ├── PyramidDemoUI.class
│ │ └── sift
│ │ │ ├── Feature.class
│ │ │ ├── Float2DArray.class
│ │ │ ├── GaussianUtil.class
│ │ │ ├── OctaveKeyPointersDetector.class
│ │ │ ├── SIFTFeatureDetector.class
│ │ │ └── ScaleOctave.class
│ ├── three
│ │ ├── ImagePanel.class
│ │ └── MainUI.class
│ ├── twelves
│ │ ├── ClusterCenter.class
│ │ ├── FCClusterCenter.class
│ │ ├── FuzzyCMeansAlgo.class
│ │ ├── KMeansAlgo.class
│ │ ├── MeanPoint.class
│ │ ├── MeanShiftAlgo.class
│ │ ├── OtsuBinaryFilter.class
│ │ ├── PixelPoint.class
│ │ ├── SobelEdgeFilter.class
│ │ └── WatershedSegmentationAlgo.class
│ └── two
│ │ ├── BufferedImageDemo.class
│ │ ├── ColorModelDemo.class
│ │ ├── MyFilterUI.class
│ │ ├── MyFilters.class
│ │ └── lena.jpg
│ └── image
│ └── util
│ ├── ImageMath.class
│ ├── lena.png
│ └── lena_gray.png
├── lib
└── Jama-1.0.3.jar
└── src
└── com
└── book
├── chapter
├── eight
│ ├── BilateralFilter.java
│ ├── BlurFilter.java
│ ├── BoxBlurFilter.java
│ ├── ConvolutionFilter.java
│ ├── GaussianBlurFilter.java
│ ├── LaplacianSharpenFilter.java
│ ├── PixellateFilter.java
│ ├── SmoothFilter.java
│ ├── StatisticsFilter.java
│ ├── moon.png
│ └── noiselena.png
├── eleven
│ ├── A-Set.png
│ ├── B-Set.png
│ ├── BoundaryExtractionFilter.java
│ ├── CloseFilter.java
│ ├── DilationFilter.java
│ ├── DistanceTransform.java
│ ├── ErosionFilter.java
│ ├── FIFOQueue.java
│ ├── GrayDilationFilter.java
│ ├── GrayErosionFilter.java
│ ├── HitAndMissFilter.java
│ ├── OpenFilter.java
│ ├── PixelPoint.java
│ ├── SetOperatorFilter.java
│ ├── WatershedTransform.java
│ ├── close.png
│ ├── open.png
│ ├── person.png
│ └── watershed_test.png
├── five
│ ├── BitBltFilter.java
│ ├── BitBltFilterTest.java
│ ├── BlendFilter.java
│ ├── NatureFilter.java
│ ├── PMMDFilter.java
│ └── rainbow.png
├── four
│ ├── AbstractBufferedImageOp.java
│ ├── BCSAdjustFilter.java
│ ├── BrightContrastSatUI.java
│ ├── BrightFilter.java
│ ├── ContrastFilter.java
│ ├── SaturationFilter.java
│ └── SepiaToneFilter.java
├── fourteen
│ ├── MainUI.java
│ ├── MomentsUtil.java
│ ├── ScaleFilter.java
│ ├── StrokeAreaFilter.java
│ ├── StrokeElement.java
│ ├── StrokeGenerator.java
│ ├── StrokePaintlyMain.java
│ ├── rainbow-fish-md.png
│ └── stroke.png
├── nine
│ ├── CannyEdgeFilter.java
│ ├── GradientEdgeFilter.java
│ ├── LaplacianFilter.java
│ ├── RobotFilter.java
│ ├── SobolPrewittEdgeDetector.java
│ └── cameraman.png
├── one
│ ├── AMERSN.ttf
│ ├── CustomJPanel.java
│ ├── FontDemo.java
│ ├── GeneralPathDemo.java
│ ├── JAVA2DDemo.java
│ ├── StrokeDemo.java
│ ├── TaijiDemo.java
│ └── lena.jpg
├── seven
│ ├── BiLineRotateFilter.java
│ ├── BicubicSharpenFilter.java
│ ├── BicubicZoomFilter.java
│ ├── BilinearZoomFilter.java
│ ├── FastRotateFilter.java
│ ├── LanczosZoomFilter.java
│ ├── NearestZoomFilter.java
│ ├── XShearFilter.java
│ ├── YShearFilter.java
│ └── ZoomFilter.java
├── six
│ ├── BinaryFilter.java
│ ├── HistogramComparisonFilter.java
│ ├── HistogramDataExtractor.java
│ ├── HistogramEFilter.java
│ ├── HistogramFilter.java
│ ├── HistogramPanel.java
│ ├── PixelStatisticFilter.java
│ ├── RGBHistogramFilter.java
│ ├── RedLineMonitor.java
│ ├── ViewCallBack.java
│ ├── blank.jpg
│ ├── emd
│ │ ├── Feature.java
│ │ ├── Feature2D.java
│ │ ├── JFastEMD.java
│ │ ├── Signature.java
│ │ ├── Test.java
│ │ └── Util.java
│ └── lena_gray.png
├── ten
│ ├── AreaCenterFilter.java
│ ├── AreaOrientationFilter.java
│ ├── BFSAlgorithm.java
│ ├── BinaryDitherFilter.java
│ ├── BinaryEdgeFilter.java
│ ├── DFSAlgorithm.java
│ ├── FloodFillAlgorithm.java
│ ├── FloodFillUI.java
│ ├── GeometricMomentsAlg.java
│ ├── HalftoneFilter.java
│ ├── LabelledConnectedRegionAlg.java
│ ├── MooreNeighbourTraceAlgorithm.java
│ ├── MyQueue.java
│ ├── MyStack.java
│ ├── PixelPoint.java
│ ├── SquareTraceAlgorithm.java
│ ├── ThinPixel.java
│ ├── ZhangSuenThinningAlg.java
│ ├── area-angle.png
│ ├── binaryobject.png
│ ├── brain.png
│ ├── connectedcomponents.png
│ └── tools.png
├── thirteen
│ ├── CircleHough.java
│ ├── CoOccurrenceMatrixFilter.java
│ ├── ColorFeatureExtractor.java
│ ├── GaussianDerivativeFilter.java
│ ├── GaussianFilter.java
│ ├── GrayFilter.java
│ ├── HarrisCornerDetector.java
│ ├── HarrisMatrix.java
│ ├── HoughFilter.java
│ ├── LineHough.java
│ ├── PyramidAlgorithm.java
│ ├── PyramidDemoUI.java
│ └── sift
│ │ ├── Feature.java
│ │ ├── Float2DArray.java
│ │ ├── GaussianUtil.java
│ │ ├── OctaveKeyPointersDetector.java
│ │ ├── SIFTFeatureDetector.java
│ │ └── ScaleOctave.java
├── three
│ ├── ImagePanel.java
│ └── MainUI.java
├── twelves
│ ├── ClusterCenter.java
│ ├── FCClusterCenter.java
│ ├── FuzzyCMeansAlgo.java
│ ├── KMeansAlgo.java
│ ├── MeanPoint.java
│ ├── MeanShiftAlgo.java
│ ├── OtsuBinaryFilter.java
│ ├── PixelPoint.java
│ ├── SobelEdgeFilter.java
│ └── WatershedSegmentationAlgo.java
└── two
│ ├── BufferedImageDemo.java
│ ├── ColorModelDemo.java
│ ├── MyFilterUI.java
│ ├── MyFilters.java
│ └── lena.jpg
└── image
└── util
├── ImageMath.java
├── lena.png
└── lena_gray.png
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | mybook
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/com/book/chapter/eleven/PixelPoint.java=UTF-8
3 | encoding//src/com/book/chapter/eleven/WatershedTransform.java=UTF-8
4 | encoding//src/com/book/chapter/thirteen/CircleHough.java=UTF-8
5 | encoding//src/com/book/chapter/thirteen/LineHough.java=UTF-8
6 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.6
12 |
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/BilateralFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/BilateralFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/BlurFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/BlurFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/BoxBlurFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/BoxBlurFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/ConvolutionFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/ConvolutionFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/GaussianBlurFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/GaussianBlurFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/LaplacianSharpenFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/LaplacianSharpenFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/PixellateFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/PixellateFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/SmoothFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/SmoothFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/StatisticsFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/StatisticsFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/moon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/moon.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/eight/noiselena.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eight/noiselena.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/A-Set.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/A-Set.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/B-Set.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/B-Set.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/BoundaryExtractionFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/BoundaryExtractionFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/CloseFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/CloseFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/DilationFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/DilationFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/DistanceTransform.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/DistanceTransform.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/ErosionFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/ErosionFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/FIFOQueue.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/FIFOQueue.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/GrayDilationFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/GrayDilationFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/GrayErosionFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/GrayErosionFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/HitAndMissFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/HitAndMissFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/OpenFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/OpenFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/PixelPoint.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/PixelPoint.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/SetOperatorFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/SetOperatorFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/WatershedTransform.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/WatershedTransform.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/close.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/open.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/person.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/person.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/eleven/watershed_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/eleven/watershed_test.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/five/BitBltFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/five/BitBltFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/five/BitBltFilterTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/five/BitBltFilterTest.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/five/BlendFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/five/BlendFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/five/NatureFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/five/NatureFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/five/PMMDFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/five/PMMDFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/five/rainbow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/five/rainbow.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/four/AbstractBufferedImageOp.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/four/AbstractBufferedImageOp.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/four/BCSAdjustFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/four/BCSAdjustFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/four/BrightContrastSatUI.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/four/BrightContrastSatUI.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/four/BrightFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/four/BrightFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/four/ContrastFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/four/ContrastFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/four/SaturationFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/four/SaturationFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/four/SepiaToneFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/four/SepiaToneFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/MainUI$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/MainUI$1.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/MainUI.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/MainUI.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/MomentsUtil.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/MomentsUtil.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/ScaleFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/ScaleFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/StrokeAreaFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/StrokeAreaFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/StrokeElement.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/StrokeElement.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/StrokeGenerator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/StrokeGenerator.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/StrokePaintlyMain.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/StrokePaintlyMain.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/rainbow-fish-md.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/rainbow-fish-md.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/fourteen/stroke.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/fourteen/stroke.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/nine/CannyEdgeFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/nine/CannyEdgeFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/nine/GradientEdgeFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/nine/GradientEdgeFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/nine/LaplacianFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/nine/LaplacianFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/nine/RobotFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/nine/RobotFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/nine/SobolPrewittEdgeDetector.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/nine/SobolPrewittEdgeDetector.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/nine/cameraman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/nine/cameraman.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/one/AMERSN.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/one/AMERSN.ttf
--------------------------------------------------------------------------------
/bin/com/book/chapter/one/CustomJPanel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/one/CustomJPanel.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/one/FontDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/one/FontDemo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/one/GeneralPathDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/one/GeneralPathDemo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/one/JAVA2DDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/one/JAVA2DDemo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/one/StrokeDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/one/StrokeDemo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/one/TaijiDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/one/TaijiDemo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/one/lena.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/one/lena.jpg
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/BiLineRotateFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/BiLineRotateFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/BicubicSharpenFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/BicubicSharpenFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/BicubicZoomFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/BicubicZoomFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/BilinearZoomFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/BilinearZoomFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/FastRotateFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/FastRotateFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/LanczosZoomFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/LanczosZoomFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/NearestZoomFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/NearestZoomFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/XShearFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/XShearFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/YShearFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/YShearFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/seven/ZoomFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/seven/ZoomFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/BinaryFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/BinaryFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/HistogramComparisonFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/HistogramComparisonFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/HistogramDataExtractor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/HistogramDataExtractor.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/HistogramEFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/HistogramEFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/HistogramFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/HistogramFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/HistogramPanel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/HistogramPanel.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/PixelStatisticFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/PixelStatisticFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/RGBHistogramFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/RGBHistogramFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/RedLineMonitor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/RedLineMonitor.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/ViewCallBack.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/ViewCallBack.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/blank.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/blank.jpg
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Edge.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Edge.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Edge0.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Edge0.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Edge1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Edge1.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Edge2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Edge2.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Edge3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Edge3.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Feature.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Feature.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Feature2D.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Feature2D.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/JFastEMD.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/JFastEMD.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/MinCostFlow.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/MinCostFlow.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Signature.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Signature.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/emd/Test.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/emd/Test.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/six/lena_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/six/lena_gray.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/AreaCenterFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/AreaCenterFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/AreaOrientationFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/AreaOrientationFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/BFSAlgorithm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/BFSAlgorithm.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/BinaryDitherFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/BinaryDitherFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/BinaryEdgeFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/BinaryEdgeFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/DFSAlgorithm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/DFSAlgorithm.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/FloodFillAlgorithm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/FloodFillAlgorithm.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/FloodFillUI.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/FloodFillUI.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/GeometricMomentsAlg.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/GeometricMomentsAlg.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/HalftoneFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/HalftoneFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/LabelledConnectedRegionAlg.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/LabelledConnectedRegionAlg.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/MooreNeighbourTraceAlgorithm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/MooreNeighbourTraceAlgorithm.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/MyQueue.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/MyQueue.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/MyStack.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/MyStack.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/PixelPoint.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/PixelPoint.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/SquareTraceAlgorithm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/SquareTraceAlgorithm.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/ThinPixel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/ThinPixel.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/ZhangSuenThinningAlg.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/ZhangSuenThinningAlg.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/area-angle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/area-angle.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/binaryobject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/binaryobject.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/brain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/brain.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/connectedcomponents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/connectedcomponents.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/ten/tools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/ten/tools.png
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/CircleHough.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/CircleHough.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/CoOccurrenceMatrixFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/CoOccurrenceMatrixFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/ColorFeatureExtractor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/ColorFeatureExtractor.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/GaussianDerivativeFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/GaussianDerivativeFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/GaussianFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/GaussianFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/GrayFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/GrayFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/HarrisCornerDetector.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/HarrisCornerDetector.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/HarrisMatrix.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/HarrisMatrix.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/HoughFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/HoughFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/LineHough.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/LineHough.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/PyramidAlgorithm.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/PyramidAlgorithm.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/PyramidDemoUI.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/PyramidDemoUI.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/sift/Feature.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/sift/Feature.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/sift/Float2DArray.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/sift/Float2DArray.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/sift/GaussianUtil.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/sift/GaussianUtil.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/sift/OctaveKeyPointersDetector.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/sift/OctaveKeyPointersDetector.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/sift/SIFTFeatureDetector.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/sift/SIFTFeatureDetector.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/thirteen/sift/ScaleOctave.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/thirteen/sift/ScaleOctave.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/three/ImagePanel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/three/ImagePanel.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/three/MainUI.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/three/MainUI.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/ClusterCenter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/ClusterCenter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/FCClusterCenter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/FCClusterCenter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/FuzzyCMeansAlgo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/FuzzyCMeansAlgo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/KMeansAlgo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/KMeansAlgo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/MeanPoint.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/MeanPoint.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/MeanShiftAlgo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/MeanShiftAlgo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/OtsuBinaryFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/OtsuBinaryFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/PixelPoint.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/PixelPoint.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/SobelEdgeFilter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/SobelEdgeFilter.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/twelves/WatershedSegmentationAlgo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/twelves/WatershedSegmentationAlgo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/two/BufferedImageDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/two/BufferedImageDemo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/two/ColorModelDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/two/ColorModelDemo.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/two/MyFilterUI.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/two/MyFilterUI.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/two/MyFilters.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/two/MyFilters.class
--------------------------------------------------------------------------------
/bin/com/book/chapter/two/lena.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/chapter/two/lena.jpg
--------------------------------------------------------------------------------
/bin/com/book/image/util/ImageMath.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/image/util/ImageMath.class
--------------------------------------------------------------------------------
/bin/com/book/image/util/lena.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/image/util/lena.png
--------------------------------------------------------------------------------
/bin/com/book/image/util/lena_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/bin/com/book/image/util/lena_gray.png
--------------------------------------------------------------------------------
/lib/Jama-1.0.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/lib/Jama-1.0.3.jar
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/BilateralFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eight/BilateralFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/BlurFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.eight;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class BlurFilter extends AbstractBufferedImageOp {
8 |
9 | private int[][] kernels= new int[][]{{1,1,1}, {1,1,1}, {1,1,1}};
10 |
11 | public BlurFilter()
12 | {
13 | System.out.println("goldfish-filter");
14 | }
15 |
16 | public void setKernels(int[][] kernels) {
17 | this.kernels = kernels;
18 | }
19 |
20 | @Override
21 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
22 | int width = src.getWidth();
23 | int height = src.getHeight();
24 |
25 | if (dest == null)
26 | dest = createCompatibleDestImage(src, null);
27 |
28 | int[] inPixels = new int[width * height];
29 | int[] outPixels = new int[width * height];
30 | getRGB(src, 0, 0, width, height, inPixels);
31 | int index = 0;
32 | int kwRaduis = kernels[0].length/2;
33 | int khRaduis = kernels.length/2;
34 | double total = kernels.length * kernels.length;
35 | for (int row = 0; row < height; row++) {
36 | int ta = 0, tr = 0, tg = 0, tb = 0;
37 | for (int col = 0; col < width; col++) {
38 | index = row * width + col;
39 | for(int subRow=-khRaduis; subRow<=khRaduis; subRow++)
40 | {
41 | int nrow = row + subRow;
42 | if(nrow < 0 || nrow >= height)
43 | {
44 | nrow = 0;
45 | }
46 | for(int subCol=-kwRaduis; subCol<=kwRaduis; subCol++)
47 | {
48 | int ncol = col + subCol;
49 | if(ncol < 0 || ncol >= width)
50 | {
51 | ncol = 0;
52 | }
53 | int index1 = nrow * width + ncol;
54 | ta = (inPixels[index1] >> 24) & 0xff;
55 | tr += (inPixels[index1] >> 16) & 0xff;
56 | tg += (inPixels[index1] >> 8) & 0xff;
57 | tb += inPixels[index1] & 0xff;
58 | }
59 | }
60 | tr = (int)(tr / total);
61 | tg = (int)(tg / total);
62 | tb = (int)(tb / total);
63 | outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;
64 |
65 | // clean up for next pixel
66 | tr = 0;
67 | tg = 0;
68 | tb = 0;
69 | }
70 | }
71 | setRGB(dest, 0, 0, width, height, outPixels);
72 | return dest;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/BoxBlurFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eight/BoxBlurFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/ConvolutionFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.eight;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class ConvolutionFilter extends AbstractBufferedImageOp {
8 | public final static int ZERO_EXTEND = 1;
9 | public final static int WRAP = 2;
10 | public final static int CROP = 4;
11 |
12 | private int edgeAction;
13 | private float[] kernels;
14 |
15 | public ConvolutionFilter()
16 | {
17 | edgeAction = CROP;
18 | }
19 |
20 | public int getEdgeAction() {
21 | return edgeAction;
22 | }
23 |
24 | public void setEdgeAction(int edgeAction) {
25 | this.edgeAction = edgeAction;
26 | }
27 |
28 | public float[] getKernels() {
29 | return kernels;
30 | }
31 |
32 | public void setKernels(float[] kernels) {
33 | this.kernels = kernels;
34 | }
35 |
36 | @Override
37 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
38 | int width = src.getWidth();
39 | int height = src.getHeight();
40 |
41 | if ( dest == null )
42 | dest = createCompatibleDestImage( src, null );
43 |
44 | int[] inPixels = new int[width*height];
45 | int[] outPixels = new int[width*height];
46 | getRGB( src, 0, 0, width, height, inPixels );
47 |
48 | // normalization kernels
49 | float sum = 0.0f;
50 | for(int i=0; i=0 && offsetCol < width)
86 | {
87 | index = row * width + offsetCol;
88 | }
89 | // handle edge pixels
90 | else if(edgeAction == ZERO_EXTEND)
91 | {
92 | continue;
93 | }
94 | else if(edgeAction == WRAP)
95 | {
96 | int ncol = offsetCol / width;
97 | offsetCol = offsetCol-(ncol * width); // wrap col
98 | if(offsetCol < 0)
99 | offsetCol += width;
100 | }
101 | else if(edgeAction == CROP)
102 | {
103 | if(offsetCol < 0)
104 | offsetCol = 0;
105 | else if(offsetCol >= width)
106 | offsetCol = width - 1;
107 | }
108 | index = row * width + offsetCol;
109 | int rgb = inPixels[index];
110 | sumr += kernels2[cr+nr] * ((rgb >> 16) & 0xff);
111 | sumg += kernels2[cr+nr] * ((rgb >> 8) & 0xff);
112 | sumb += kernels2[cr+nr] * (rgb & 0xff);
113 | }
114 | index = row * width + col;
115 | outPixels[index] = (255 << 24)
116 | | (clamp(sumr) << 16)
117 | | (clamp(sumg) << 8)
118 | | clamp(sumb);
119 | }
120 | }
121 |
122 | }
123 |
124 | public int clamp(float f) {
125 | int value = (int)f;
126 | return value > 255 ? 255 :
127 | (value < 0 ? 0 : value);
128 | }
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/GaussianBlurFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.eight;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class GaussianBlurFilter extends AbstractBufferedImageOp {
8 |
9 | private int n=1;
10 | private float sigma=1;
11 |
12 | public GaussianBlurFilter()
13 | {
14 | System.out.println("Gaussian Blur Filter...");
15 | }
16 | public int getN() {
17 | return n;
18 | }
19 |
20 | public void setN(int n) {
21 | this.n = n;
22 | }
23 |
24 | public float getSigma() {
25 | return sigma;
26 | }
27 |
28 | public void setSigma(float sigma) {
29 | this.sigma = sigma;
30 | }
31 |
32 | @Override
33 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
34 | int width = src.getWidth();
35 | int height = src.getHeight();
36 |
37 | if (dest == null)
38 | dest = createCompatibleDestImage(src, null);
39 |
40 | int[] inPixels = new int[width * height];
41 | int[] outPixels = new int[width * height];
42 | getRGB(src, 0, 0, width, height, inPixels);
43 | int index = 0;
44 | float[][] kernels = get2DKernalData(n, sigma);
45 | int kwRaduis = kernels[0].length/2;
46 | int khRaduis = kernels.length/2;
47 | for (int row = 0; row < height; row++) {
48 | int ta = 0, tr = 0, tg = 0, tb = 0;
49 | for (int col = 0; col < width; col++) {
50 | index = row * width + col;
51 | double weightSum = 0.0;
52 | double redSum = 0, greenSum = 0, blurSum = 0;
53 | for(int subRow=-khRaduis; subRow<=khRaduis; subRow++)
54 | {
55 | int nrow = row + subRow;
56 | if(nrow < 0 || nrow >= height)
57 | {
58 | nrow = 0;
59 | }
60 | for(int subCol=-kwRaduis; subCol<=kwRaduis; subCol++)
61 | {
62 | int ncol = col + subCol;
63 | if(ncol < 0 || ncol >= width)
64 | {
65 | ncol = 0;
66 | }
67 | int index1 = nrow * width + ncol;
68 | int ta1 = (inPixels[index1] >> 24) & 0xff;
69 | int tr1 = (inPixels[index1] >> 16) & 0xff;
70 | int tg1 = (inPixels[index1] >> 8) & 0xff;
71 | int tb1 = inPixels[index1] & 0xff;
72 | redSum += tr1 * kernels[subRow + khRaduis][subCol + kwRaduis];
73 | greenSum += tg1 * kernels[subRow + khRaduis][subCol + kwRaduis];
74 | blurSum += tb1 * kernels[subRow + khRaduis][subCol + kwRaduis];
75 | weightSum += kernels[subRow + khRaduis][subCol + kwRaduis];
76 | }
77 | }
78 | tr = (int)(redSum / weightSum);
79 | tg = (int)(greenSum / weightSum);
80 | tb = (int)(blurSum / weightSum);
81 | outPixels[index] = (255 << 24) | (tr << 16) | (tg << 8) | tb;
82 |
83 | // clean up for next pixel
84 | tr = 0;
85 | tg = 0;
86 | tb = 0;
87 | }
88 | }
89 | setRGB(dest, 0, 0, width, height, outPixels);
90 | return dest;
91 | }
92 |
93 | public float[][] get2DKernalData(int n, float sigma) {
94 | int size = 2*n +1;
95 | float sigma22 = 2*sigma*sigma;
96 | float sigma22PI = (float)Math.PI * sigma22;
97 | float[][] kernalData = new float[size][size];
98 | int row = 0;
99 | for(int i=-n; i<=n; i++) {
100 | int column = 0;
101 | for(int j=-n; j<=n; j++) {
102 | float xDistance = i*i;
103 | float yDistance = j*j;
104 | kernalData[row][column] = (float)Math.exp(-(xDistance
105 | + yDistance)/sigma22)/sigma22PI;
106 | column++;
107 | }
108 | row++;
109 | }
110 | return kernalData;
111 | }
112 |
113 | private float[] get1DKernelData(int n, float sigma) {
114 | float sigma22 = 2*sigma*sigma;
115 | float Pi2 = 2*(float)Math.PI;
116 | float sqrtSigmaPi2 = (float)Math.sqrt(Pi2) * sigma ;
117 | int size = 2*n + 1;
118 | int index = 0;
119 | float[] kernalData = new float[size];
120 | for(int i=-n; i<=n; i++) {
121 | float distance = i*i;
122 | kernalData[index] = (float)Math.exp((-distance)
123 | /sigma22)/sqrtSigmaPi2;
124 | index++;
125 | }
126 | return kernalData;
127 | }
128 |
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/LaplacianSharpenFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eight/LaplacianSharpenFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/PixellateFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eight/PixellateFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/SmoothFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eight/SmoothFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/StatisticsFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eight/StatisticsFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/moon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eight/moon.png
--------------------------------------------------------------------------------
/src/com/book/chapter/eight/noiselena.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eight/noiselena.png
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/A-Set.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/A-Set.png
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/B-Set.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/B-Set.png
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/BoundaryExtractionFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/BoundaryExtractionFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/CloseFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/CloseFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/DilationFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/DilationFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/DistanceTransform.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/DistanceTransform.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/ErosionFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/ErosionFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/FIFOQueue.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.eleven;
2 |
3 | import java.util.LinkedList;
4 |
5 | public class FIFOQueue {
6 | private LinkedList watershedFIFO;
7 |
8 | public FIFOQueue() {
9 | watershedFIFO = new LinkedList();
10 | }
11 |
12 | public void fifo_add(PixelPoint p) {
13 | watershedFIFO.addFirst(p);
14 | }
15 |
16 | public PixelPoint fifo_remove() {
17 | return (PixelPoint) watershedFIFO.removeLast();
18 | }
19 |
20 | public boolean fifo_empty() {
21 | return watershedFIFO.isEmpty();
22 | }
23 |
24 | public void fifo_add_FICTITIOUS() {
25 | watershedFIFO.addFirst(new PixelPoint());
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/GrayDilationFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.eleven;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class GrayDilationFilter extends AbstractBufferedImageOp {
8 |
9 | private int[][] elements;
10 |
11 | public GrayDilationFilter() {
12 | System.out.println("Gray Image Dilation Filter...");
13 | }
14 |
15 | public int[][] getElements() {
16 | return elements;
17 | }
18 |
19 | public void setElements(int[][] elements) {
20 | this.elements = elements;
21 | }
22 |
23 | @Override
24 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
25 | int width = src.getWidth();
26 | int height = src.getHeight();
27 |
28 | if (dest == null)
29 | dest = createCompatibleDestImage(src, null);
30 |
31 | int[] inPixels = new int[width * height];
32 | int[] outPixels = new int[width * height];
33 | getRGB(src, 0, 0, width, height, inPixels);
34 | int index = 0;
35 | int s = elements[0].length;
36 | int t = elements.length;
37 | int max = 0;
38 | for (int row = 0; row < height; row++) {
39 | int tg = 0;
40 | for (int col = 0; col < width; col++) {
41 | index = row * width + col;
42 | max = 0;
43 | for(int subRow=0; subRow= height)
47 | {
48 | nrow = 0;
49 | }
50 | for(int subCol=0; subCol= width)
54 | {
55 | ncol = 0;
56 | }
57 | int index1 = nrow * width + ncol;
58 | tg = (inPixels[index1] >> 8) & 0xff;
59 | max = Math.max(tg, max);
60 | }
61 | }
62 | outPixels[index] = (255 << 24) | (max << 16) | (max << 8) | max;
63 | }
64 | }
65 | setRGB(dest, 0, 0, width, height, outPixels);
66 | return dest;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/GrayErosionFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.eleven;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class GrayErosionFilter extends AbstractBufferedImageOp {
8 |
9 | private int[][] elements;
10 |
11 | public GrayErosionFilter()
12 | {
13 | System.out.println("Gray Image Erosion Filter...");
14 | }
15 |
16 | public int[][] getElements() {
17 | return elements;
18 | }
19 |
20 | public void setElements(int[][] elements) {
21 | this.elements = elements;
22 | }
23 |
24 | @Override
25 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
26 | int width = src.getWidth();
27 | int height = src.getHeight();
28 |
29 | if (dest == null)
30 | dest = createCompatibleDestImage(src, null);
31 |
32 | int[] inPixels = new int[width * height];
33 | int[] outPixels = new int[width * height];
34 | getRGB(src, 0, 0, width, height, inPixels);
35 | int index = 0;
36 | int s = elements[0].length;
37 | int t = elements.length;
38 | int min = 255;
39 | for (int row = 0; row < height; row++) {
40 | int tg = 0;
41 | for (int col = 0; col < width; col++) {
42 | index = row * width + col;
43 | min = 255;
44 | for(int subRow=0; subRow= height)
48 | {
49 | nrow = 0;
50 | }
51 | for(int subCol=0; subCol= width)
55 | {
56 | ncol = 0;
57 | }
58 | int index1 = nrow * width + ncol;
59 | tg = (inPixels[index1] >> 8) & 0xff;
60 | min = Math.min(tg, min);
61 | }
62 | }
63 | outPixels[index] = (255 << 24) | (min << 16) | (min << 8) | min;
64 | }
65 | }
66 | setRGB(dest, 0, 0, width, height, outPixels);
67 | return dest;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/HitAndMissFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/HitAndMissFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/OpenFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/OpenFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/PixelPoint.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.eleven;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class PixelPoint implements Comparable {
7 | public final static int INIT = -1;
8 | public final static int MASK = -2;
9 | public final static int WSHED = 0;
10 |
11 | private int row;
12 | private int col;
13 | private int level;
14 | private int label;
15 | private int distance;
16 | private List neighbours;
17 |
18 | public PixelPoint(int row, int col, int gray) {
19 | this.row = row;
20 | this.col = col;
21 | this.level = gray;
22 | this.label = INIT;
23 | this.neighbours = new ArrayList();
24 | }
25 |
26 | public PixelPoint() {
27 | this.level = -100;
28 | }
29 |
30 | public int getRow() {
31 | return row;
32 | }
33 |
34 | public void setRow(int row) {
35 | this.row = row;
36 | }
37 |
38 | public int getCol() {
39 | return col;
40 | }
41 |
42 | public void setCol(int col) {
43 | this.col = col;
44 | }
45 |
46 | public int getLevel() {
47 | return level;
48 | }
49 |
50 | public void setLevel(int level) {
51 | this.level = level;
52 | }
53 |
54 | public int getLabel() {
55 | return label;
56 | }
57 |
58 | public void setLabel(int label) {
59 | this.label = label;
60 | }
61 |
62 | public void setLabelToINIT() {
63 | label = INIT;
64 | }
65 |
66 | public void setLabelToMASK() {
67 | label = MASK;
68 | }
69 |
70 | public void setLabelToWSHED() {
71 | label = WSHED;
72 | }
73 |
74 | public boolean isLabelINIT() {
75 | return label == INIT;
76 | }
77 |
78 | public boolean isLabelMASK() {
79 | return label == MASK;
80 | }
81 |
82 | public boolean isLabelWSHED() {
83 | return label == WSHED;
84 | }
85 |
86 | public boolean isFictitious()
87 | {
88 | return (level == -100);
89 | }
90 |
91 | public int getDistance() {
92 | return distance;
93 | }
94 |
95 | public void setDistance(int distance) {
96 | this.distance = distance;
97 | }
98 |
99 | public List getNeighbours() {
100 | return neighbours;
101 | }
102 |
103 | public void setNeighbours(List neighbours) {
104 | this.neighbours = neighbours;
105 | }
106 |
107 | public boolean allNeighboursAreWSHED()
108 | {
109 | boolean result = true;
110 | for(PixelPoint p :neighbours)
111 | {
112 | if(!p.isLabelWSHED())
113 | {
114 | result = false;
115 | break;
116 | }
117 | }
118 | return result;
119 | }
120 |
121 | @Override
122 | public int compareTo(PixelPoint pp) {
123 | if (pp.getLevel() < getLevel())
124 | return 1;
125 | else if (pp.getLevel() > getLevel())
126 | return -1;
127 | else
128 | return 0;
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/SetOperatorFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/SetOperatorFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/close.png
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/open.png
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/person.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/person.png
--------------------------------------------------------------------------------
/src/com/book/chapter/eleven/watershed_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/eleven/watershed_test.png
--------------------------------------------------------------------------------
/src/com/book/chapter/five/BitBltFilterTest.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.five;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Dimension;
5 | import java.awt.Graphics;
6 | import java.awt.Graphics2D;
7 | import java.awt.image.BufferedImage;
8 | import java.io.File;
9 | import java.io.IOException;
10 |
11 | import javax.imageio.ImageIO;
12 | import javax.swing.JComponent;
13 | import javax.swing.JFileChooser;
14 | import javax.swing.JFrame;
15 |
16 |
17 | public class BitBltFilterTest extends JComponent {
18 | /**
19 | *
20 | */
21 | private static final long serialVersionUID = 7462704254856439832L;
22 | private BufferedImage textImg;
23 | private BufferedImage targetImg;
24 | private Dimension mySize;
25 | public BitBltFilterTest(File f) {
26 | try {
27 | textImg = ImageIO.read(f);
28 | targetImg = ImageIO.read(new File("D:\\resource\\yourImage.png"));
29 | } catch (IOException e) {
30 | e.printStackTrace();
31 | }
32 | mySize = new Dimension(2*targetImg.getWidth() + 20, targetImg.getHeight()+ 100);
33 | filterImage();
34 | final JFrame imageFrame = new JFrame("Emboss Text - gloomyfish");
35 | imageFrame.getContentPane().setLayout(new BorderLayout());
36 | imageFrame.getContentPane().add(this, BorderLayout.CENTER);
37 | imageFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
38 | imageFrame.pack();
39 | imageFrame.setVisible(true);
40 | }
41 |
42 | private void filterImage() {
43 | BitBltFilter filter = new BitBltFilter();
44 | filter.emboss(textImg, targetImg);
45 | }
46 |
47 | public void paint(Graphics g) {
48 | Graphics2D g2 = (Graphics2D) g;
49 | g2.drawImage(textImg, 0, 0, textImg.getWidth(), textImg.getHeight(), null);
50 | g2.drawImage(targetImg, textImg.getWidth()+10, 0, targetImg.getWidth(), targetImg.getHeight(), null);
51 | g2.drawString("text image", textImg.getWidth()/2, textImg.getHeight()+10);
52 | g2.drawString("sharped text in image", targetImg.getWidth() + 10, targetImg.getHeight()+10);
53 | }
54 | public Dimension getPreferredSize() {
55 | return mySize;
56 | }
57 |
58 | public Dimension getMinimumSize() {
59 | return mySize;
60 | }
61 |
62 | public Dimension getMaximumSize() {
63 | return mySize;
64 | }
65 |
66 | public static void main(String[] args) {
67 | JFileChooser chooser = new JFileChooser();
68 | chooser.showOpenDialog(null);
69 | File f = chooser.getSelectedFile();
70 | new BitBltFilterTest(f);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/com/book/chapter/five/BlendFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.five;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class BlendFilter extends AbstractBufferedImageOp {
8 |
9 | public final static int MULTIPLY_PIXEL = 1;
10 | public final static int PLUS_PIXEL = 2;
11 | public final static int MINUS_PIXEL = 3;
12 | public final static int INVERSE_PIXEL = 4;
13 | public final static int INVERSE_PLUS_PIXEL = 5;
14 | public final static int DIVISION_PIXEL = 6;
15 |
16 | private int MODE;
17 | private BufferedImage secondImage;
18 |
19 | public BlendFilter() {
20 | MODE = MULTIPLY_PIXEL;
21 | }
22 |
23 | public void setBlendMode(int mode) {
24 | this.MODE = mode;
25 | }
26 |
27 | public void setSecondImage(BufferedImage image) {
28 | this.secondImage = image;
29 | }
30 |
31 | @Override
32 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
33 | checkImages(src);
34 | int width = src.getWidth();
35 | int height = src.getHeight();
36 |
37 | if (dest == null)
38 | dest = createCompatibleDestImage(src, null);
39 |
40 | int[] input1 = new int[width * height];
41 | int[] input2 = new int[secondImage.getWidth() * secondImage.getHeight()];
42 | int[] outPixels = new int[width * height];
43 | getRGB(src, 0, 0, width, height, input1);
44 | getRGB(secondImage, 0, 0, secondImage.getWidth(),
45 | secondImage.getHeight(), input2);
46 | int index = 0;
47 | int ta1 = 0, tr1 = 0, tg1 = 0, tb1 = 0;
48 | for (int row = 0; row < height; row++) {
49 | for (int col = 0; col < width; col++) {
50 | index = row * width + col;
51 | ta1 = (input1[index] >> 24) & 0xff;
52 | tr1 = (input1[index] >> 16) & 0xff;
53 | tg1 = (input1[index] >> 8) & 0xff;
54 | tb1 = input1[index] & 0xff;
55 | int[] rgb = getBlendData(tr1, tg1, tb1, input2, row, col);
56 | outPixels[index] = (ta1 << 24) | (rgb[0] << 16) | (rgb[1] << 8)
57 | | rgb[2];
58 |
59 | }
60 | }
61 | setRGB(dest, 0, 0, width, height, outPixels);
62 | return dest;
63 | }
64 |
65 | private int[] getBlendData(int tr1, int tg1, int tb1, int[] input, int row,
66 | int col) {
67 | int width = secondImage.getWidth();
68 | int height = secondImage.getHeight();
69 | if (col >= width || row >= height) {
70 | return new int[] { tr1, tg1, tb1 };
71 | }
72 | int index = row * width + col;
73 | int tr = (input[index] >> 16) & 0xff;
74 | int tg = (input[index] >> 8) & 0xff;
75 | int tb = input[index] & 0xff;
76 | int[] rgb = new int[3];
77 | if (MODE == MULTIPLY_PIXEL) {
78 | rgb[0] = modeOne(tr1, tr);
79 | rgb[1] = modeOne(tg1, tg);
80 | rgb[2] = modeOne(tb1, tb);
81 | } else if (MODE == PLUS_PIXEL) {
82 | rgb[0] = modeTwo(tr1, tr);
83 | rgb[1] = modeTwo(tg1, tg);
84 | rgb[2] = modeTwo(tb1, tb);
85 | } else if (MODE == MINUS_PIXEL) {
86 | rgb[0] = modeThree(tr1, tr);
87 | rgb[1] = modeThree(tg1, tg);
88 | rgb[2] = modeThree(tb1, tb);
89 | } else if (MODE == INVERSE_PIXEL) {
90 | rgb[0] = modeFour(tr1, tr);
91 | rgb[1] = modeFour(tg1, tg);
92 | rgb[2] = modeFour(tb1, tb);
93 | } else if (MODE == INVERSE_PLUS_PIXEL) {
94 | rgb[0] = modeFive(tr1, tr);
95 | rgb[1] = modeFive(tg1, tg);
96 | rgb[2] = modeFive(tb1, tb);
97 | } else if (MODE == DIVISION_PIXEL) {
98 | rgb[0] = modeSix(tr1, tr);
99 | rgb[1] = modeSix(tg1, tg);
100 | rgb[2] = modeSix(tb1, tb);
101 | }
102 | return rgb;
103 | }
104 |
105 | private int modeOne(int v1, int v2) {
106 | return (v1 * v2) / 255;
107 | }
108 |
109 | private int modeTwo(int v1, int v2) {
110 | return (v1 + v2) / 2;
111 | }
112 |
113 | private int modeThree(int v1, int v2) {
114 | return Math.abs(v1 - v2);
115 | }
116 |
117 | private int modeFour(double v1, double v2) {
118 | double p = (int) ((255 - v1) * (255 - v2));
119 | return (int) (255 - (p / 255));
120 | }
121 |
122 | private int modeFive(double v1, double v2) {
123 | int p = (int) (v1 + v2);
124 | if (p > 255)
125 | return 0;
126 | else
127 | return 255 - p;
128 | }
129 |
130 | private int modeSix(double v1, double v2) {
131 | if(v2 == 255)
132 | return 0;
133 | double p = (v1 / (255 - v2)) * 255;
134 | return clamp((int)p);
135 | }
136 |
137 | private void checkImages(BufferedImage src) {
138 | int width = src.getWidth();
139 | int height = src.getHeight();
140 | if (secondImage == null || secondImage.getWidth() > width
141 | || secondImage.getHeight() > height) {
142 | throw new IllegalArgumentException(
143 | "the width, height of the input image must be " +
144 | "great than blend image");
145 | }
146 | }
147 |
148 | }
149 |
--------------------------------------------------------------------------------
/src/com/book/chapter/five/PMMDFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.five;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.util.Random;
5 |
6 | import com.book.chapter.four.AbstractBufferedImageOp;
7 | /**
8 | * plus/minus/multiplication/division
9 | * @author fish
10 | *
11 | */
12 | public class PMMDFilter extends AbstractBufferedImageOp {
13 | public final static int PLUS = 1;
14 | public final static int MINUS = 2;
15 | public final static int MULTIPLE = 4;
16 |
17 | private Random rnd;
18 | private double range;
19 | private int type;
20 |
21 | public PMMDFilter()
22 | {
23 | type = MULTIPLE;
24 | rnd = new Random();
25 | range = 25.0;
26 | }
27 |
28 | @Override
29 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
30 | int width = src.getWidth();
31 | int height = src.getHeight();
32 |
33 | if (dest == null)
34 | dest = createCompatibleDestImage(src, null);
35 |
36 | int[] inPixels = new int[width * height];
37 | int[] outPixels = new int[width * height];
38 | getRGB(src, 0, 0, width, height, inPixels);
39 | int index = 0;
40 | int centerX = width/2;
41 | int centerY = height/2;
42 | double maxDistance = Math.sqrt(centerX * centerX + centerY * centerY);
43 | for (int row = 0; row < height; row++) {
44 | int ta = 0, tr = 0, tg = 0, tb = 0;
45 | for (int col = 0; col < width; col++) {
46 | index = row * width + col;
47 | ta = (inPixels[index] >> 24) & 0xff;
48 | tr = (inPixels[index] >> 16) & 0xff;
49 | tg = (inPixels[index] >> 8) & 0xff;
50 | tb = inPixels[index] & 0xff;
51 | int[] rgb = new int[]{tr, tg, tb};
52 | // plus
53 | if(type == PLUS)
54 | {
55 | rgb = plus(rgb);
56 | }
57 | // minus
58 | if(type == MINUS)
59 | {
60 | int pcol = col - 1;
61 | if(pcol < 0 || pcol >= width)
62 | {
63 | pcol = 0;
64 | }
65 | int index2 = row * width + pcol;
66 | rgb = minus(rgb, inPixels[index2]);
67 | }
68 | if(type == MULTIPLE)
69 | {
70 | rgb = multiple(rgb, maxDistance,
71 | centerX, centerY, row, col);
72 | }
73 | tr = rgb[0];
74 | tg = rgb[1];
75 | tb = rgb[2];
76 | outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;
77 |
78 | }
79 | }
80 | setRGB(dest, 0, 0, width, height, outPixels);
81 | return dest;
82 | }
83 |
84 | private int[] multiple(int[] rgb, double maxDistance,
85 | int cx, int cy, int row, int col) {
86 | double scale = 1.0 -
87 | getDistance(cx, cy, col, row)/maxDistance;
88 | scale = scale * scale;
89 | rgb[0] = (int)(scale * rgb[0]);
90 | rgb[1] = (int)(scale * rgb[1]);
91 | rgb[2] = (int)(scale * rgb[2]);
92 | return rgb;
93 | }
94 |
95 | private int[] minus(int[] rgb, int p) {
96 | int tr = (p >> 16) & 0xff;
97 | int tg = (p >> 8) & 0xff;
98 | int tb = p & 0xff;
99 | rgb[0] = clamp(rgb[0] - tr);
100 | rgb[1] = clamp(rgb[1] - tg);
101 | rgb[2] = clamp(rgb[2] - tb);
102 | return rgb;
103 | }
104 |
105 | private int[] plus(int[] rgb)
106 | {
107 | rgb[0] = addNoise(rgb[0]);
108 | rgb[1] = addNoise(rgb[1]);
109 | rgb[2] = addNoise(rgb[2]);
110 | return rgb;
111 | }
112 |
113 | private int addNoise(int p)
114 | {
115 | boolean valid = false;
116 | do {
117 | int ran = (int)Math.round(
118 | rnd.nextGaussian()*range);
119 | int v = p + ran;// pixel add noise
120 | valid = v>=0 && v<=255;
121 | if (valid) p = v;
122 | } while (!valid);
123 |
124 | return p;
125 | }
126 |
127 | private double getDistance(int cx, int cy,
128 | int px, int py) {
129 | double xx = (cx - px)*(cx - px);
130 | double yy = (cy - py)*(cy - py);
131 | return (int)Math.sqrt(xx + yy);
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/src/com/book/chapter/five/rainbow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/five/rainbow.png
--------------------------------------------------------------------------------
/src/com/book/chapter/four/BCSAdjustFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.four;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | public class BCSAdjustFilter extends AbstractBufferedImageOp {
6 | private double contrast;
7 | private double brightness;
8 | private double saturation;
9 |
10 | public double getContrast() {
11 | return contrast;
12 | }
13 |
14 | public void setContrast(double contrast) {
15 | this.contrast = contrast;
16 | }
17 |
18 | public double getBrightness() {
19 | return brightness;
20 | }
21 |
22 | public void setBrightness(double brightness) {
23 | this.brightness = brightness;
24 | }
25 |
26 | public double getSaturation() {
27 | return saturation;
28 | }
29 |
30 | public void setSaturation(double saturation) {
31 | this.saturation = saturation;
32 | }
33 |
34 | @Override
35 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
36 | handleParameters();
37 | int width = src.getWidth();
38 | int height = src.getHeight();
39 | if ( dest == null )
40 | dest = createCompatibleDestImage( src, null );
41 |
42 | int[] inPixels = new int[width*height];
43 | int[] outPixels = new int[width*height];
44 | getRGB( src, 0, 0, width, height, inPixels );
45 | int index = 0;
46 | for(int row=0; row> 24) & 0xff;
51 | tr = (inPixels[index] >> 16) & 0xff;
52 | tg = (inPixels[index] >> 8) & 0xff;
53 | tb = inPixels[index] & 0xff;
54 | double[] hsl = rgb2Hsl(new int[]{tr, tg, tb});
55 |
56 |
57 | // adjust saturation.
58 | hsl[1] = hsl[1] * saturation;
59 | if( hsl[1] < 0.0) {
60 | hsl[1] = 0.0;
61 | }
62 | if( hsl[1] > 255.0) {
63 | hsl[1] = 255.0;
64 | }
65 |
66 | // adjust brightness
67 | hsl[2] = hsl[2] * brightness;
68 | if( hsl[2] < 0.0) {
69 | hsl[2] = 0.0;
70 | }
71 | if( hsl[2] > 255.0) {
72 | hsl[2] = 255.0;
73 | }
74 |
75 | // back to RGB space
76 | int[] rgb = hsl2RGB(hsl);
77 | tr = clamp(rgb[0]);
78 | tg = clamp(rgb[1]);
79 | tb = clamp(rgb[2]);
80 |
81 | // adjust contrast
82 | double cr = ((tr /255.0d) - 0.5d) * contrast;
83 | double cg = ((tg /255.0d) - 0.5d) * contrast;
84 | double cb = ((tb /255.0d) - 0.5d) * contrast;
85 |
86 | // output RGB value
87 | tr = (int)((cr + 0.5f) * 255.0f);
88 | tg = (int)((cg + 0.5f) * 255.0f);
89 | tb = (int)((cb + 0.5f) * 255.0f);
90 |
91 | // write it back
92 | outPixels[index] = (ta << 24) | (clamp(tr) << 16)
93 | | (clamp(tg) << 8) | clamp(tb);
94 |
95 | }
96 | }
97 |
98 | setRGB( dest, 0, 0, width, height, outPixels );
99 | return dest;
100 | }
101 |
102 | private void handleParameters() {
103 | contrast = (1.0 + contrast/100.0);
104 | brightness = (1.0 + brightness/100.0);
105 | saturation = (1.0 + saturation/100.0);
106 |
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/src/com/book/chapter/four/BrightContrastSatUI.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/four/BrightContrastSatUI.java
--------------------------------------------------------------------------------
/src/com/book/chapter/four/BrightFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.four;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | public class BrightFilter extends AbstractBufferedImageOp {
6 | private float brightness;
7 |
8 | public BrightFilter() {
9 | this(1.2f);
10 | }
11 |
12 | public BrightFilter(float bright) {
13 | this.brightness = bright;
14 | }
15 |
16 | public float getBrightness() {
17 | return brightness;
18 | }
19 |
20 | public void setBrightness(float brightness) {
21 | this.brightness = brightness;
22 | }
23 |
24 | @Override
25 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
26 | int width = src.getWidth();
27 | int height = src.getHeight();
28 |
29 | if (dest == null)
30 | dest = createCompatibleDestImage(src, null);
31 |
32 | int[] inPixels = new int[width * height];
33 | int[] outPixels = new int[width * height];
34 | src.getRGB(0, 0, width, height, inPixels, 0, width);
35 |
36 | // calculate RED, GREEN, BLUE means of pixel
37 | int index = 0;
38 | int[] rgbmeans = new int[3];
39 | double redSum = 0, greenSum = 0, blueSum = 0;
40 | double total = height * width;
41 | for (int row = 0; row < height; row++) {
42 | int ta = 0, tr = 0, tg = 0, tb = 0;
43 | for (int col = 0; col < width; col++) {
44 | index = row * width + col;
45 | ta = (inPixels[index] >> 24) & 0xff;
46 | tr = (inPixels[index] >> 16) & 0xff;
47 | tg = (inPixels[index] >> 8) & 0xff;
48 | tb = inPixels[index] & 0xff;
49 | redSum += tr;
50 | greenSum += tg;
51 | blueSum += tb;
52 | }
53 | }
54 |
55 | // get means
56 | rgbmeans[0] = (int) (redSum / total);
57 | rgbmeans[1] = (int) (greenSum / total);
58 | rgbmeans[2] = (int) (blueSum / total);
59 |
60 | // adjust brightness algorithm, here
61 | for (int row = 0; row < height; row++) {
62 | int ta = 0, tr = 0, tg = 0, tb = 0;
63 | for (int col = 0; col < width; col++) {
64 | index = row * width + col;
65 | ta = (inPixels[index] >> 24) & 0xff;
66 | tr = (inPixels[index] >> 16) & 0xff;
67 | tg = (inPixels[index] >> 8) & 0xff;
68 | tb = inPixels[index] & 0xff;
69 |
70 | // remove means
71 | tr -= rgbmeans[0];
72 | tg -= rgbmeans[1];
73 | tb -= rgbmeans[2];
74 |
75 | // adjust brightness
76 | tr += (int) (rgbmeans[0] * getBrightness());
77 | tg += (int) (rgbmeans[1] * getBrightness());
78 | tb += (int) (rgbmeans[2] * getBrightness());
79 | outPixels[index] = (ta << 24) | (clamp(tr) << 16)
80 | | (clamp(tg) << 8) | clamp(tb);
81 | }
82 | }
83 | setRGB(dest, 0, 0, width, height, outPixels);
84 | return dest;
85 | }
86 |
87 | public int clamp(int value) {
88 | return value > 255 ? 255 :
89 | (value < 0 ? 0 : value);
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/com/book/chapter/four/ContrastFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.four;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | public class ContrastFilter extends AbstractBufferedImageOp {
6 |
7 | private float contrast;
8 |
9 | public ContrastFilter()
10 | {
11 | this(0.0f);
12 | }
13 |
14 | public ContrastFilter(float c)
15 | {
16 | this.contrast = c;
17 | }
18 |
19 | public float getContrast() {
20 | return contrast;
21 | }
22 |
23 | public void setContrast(float contrast) {
24 | this.contrast = contrast;
25 | }
26 |
27 | @Override
28 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
29 | int width = src.getWidth();
30 | int height = src.getHeight();
31 |
32 | if (dest == null)
33 | dest = createCompatibleDestImage(src, null);
34 |
35 | int[] inPixels = new int[width * height];
36 | int[] outPixels = new int[width * height];
37 | src.getRGB(0, 0, width, height, inPixels, 0, width);
38 |
39 | // handle user input parameter-contrast
40 | if(this.contrast > 100)
41 | {
42 | contrast = 100;
43 | }
44 | if(this.contrast < -100)
45 | {
46 | contrast = -100;
47 | }
48 | contrast = (1 + contrast / 100.0f);
49 |
50 | // adjust image contrast pixel by pixel, here
51 | int index = 0;
52 | for (int row = 0; row < height; row++) {
53 | int ta = 0, tr = 0, tg = 0, tb = 0;
54 | for (int col = 0; col < width; col++) {
55 | index = row * width + col;
56 | ta = (inPixels[index] >> 24) & 0xff;
57 | tr = (inPixels[index] >> 16) & 0xff;
58 | tg = (inPixels[index] >> 8) & 0xff;
59 | tb = inPixels[index] & 0xff;
60 |
61 | // make it more difference
62 | float cr = ((tr /255.0f) - 0.5f) * contrast;
63 | float cg = ((tg /255.0f) - 0.5f) * contrast;
64 | float cb = ((tb /255.0f) - 0.5f) * contrast;
65 |
66 | // output RGB value
67 | tr = (int)((cr + 0.5f) * 255.0f);
68 | tg = (int)((cg + 0.5f) * 255.0f);
69 | tb = (int)((cb + 0.5f) * 255.0f);
70 |
71 | // write it back
72 | outPixels[index] = (ta << 24) | (clamp(tr) << 16)
73 | | (clamp(tg) << 8) | clamp(tb);
74 | }
75 | }
76 | setRGB(dest, 0, 0, width, height, outPixels);
77 | return dest;
78 | }
79 |
80 | public int clamp(int value) {
81 | return value > 255 ? 255 :
82 | (value < 0 ? 0 : value);
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/com/book/chapter/four/SepiaToneFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.four;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | public class SepiaToneFilter extends AbstractBufferedImageOp {
6 |
7 | @Override
8 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
9 | int width = src.getWidth();
10 | int height = src.getHeight();
11 |
12 | if ( dest == null )
13 | dest = createCompatibleDestImage( src, null );
14 |
15 | int[] inPixels = new int[width*height];
16 | int[] outPixels = new int[width*height];
17 | getRGB( src, 0, 0, width, height, inPixels );
18 | int index = 0;
19 | for(int row=0; row> 24) & 0xff;
24 | tr = (inPixels[index] >> 16) & 0xff;
25 | tg = (inPixels[index] >> 8) & 0xff;
26 | tb = inPixels[index] & 0xff;
27 |
28 | //int fr= (int)(((double)tr * 0.393) + ((double)tg * 0.769) + ((double)tb * 0.189));
29 | //int fg = (int)(((double)tr * 0.349) + ((double)tg * 0.686) + ((double)tb * 0.168));
30 | //int fb= (int)(((double)tr * 0.272) + ((double)tg * 0.534) + ((double)tb * 0.131));
31 |
32 | int fr = (int)colorBlend(noise(), (tr * 0.393) + (tg * 0.769) + (tb * 0.189), tr);
33 | int fg = (int)colorBlend(noise(), (tr * 0.349) + (tg * 0.686) + (tb * 0.168), tg);
34 | int fb = (int)colorBlend(noise(), (tr * 0.272) + (tg * 0.534) + (tb * 0.131), tb);
35 |
36 | outPixels[index] = (ta << 24) | (clamp(fr) << 16) | (clamp(fg) << 8) | clamp(fb);
37 |
38 | }
39 | }
40 | setRGB( dest, 0, 0, width, height, outPixels );
41 | return dest;
42 | }
43 |
44 | private double noise() {
45 | return Math.random()*0.5 + 0.5;
46 | }
47 |
48 | private double colorBlend(double scale, double dest, double src) {
49 | return (scale * dest + (1.0 - scale) * src);
50 | }
51 | //
52 | // public static int clamp(int c)
53 | // {
54 | // return c > 255 ? 255 :( (c < 0) ? 0: c);
55 | // }
56 |
57 | public String toString()
58 | {
59 | return "Sepia Tone Effect - Effect from Photoshop App";
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/com/book/chapter/fourteen/MainUI.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.fourteen;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Dimension;
5 | import java.awt.FlowLayout;
6 | import java.awt.Graphics;
7 | import java.awt.Toolkit;
8 | import java.awt.Window;
9 | import java.awt.event.ActionEvent;
10 | import java.awt.event.ActionListener;
11 | import java.awt.image.BufferedImage;
12 | import java.io.File;
13 | import java.io.IOException;
14 |
15 | import javax.imageio.ImageIO;
16 | import javax.swing.JButton;
17 | import javax.swing.JComponent;
18 | import javax.swing.JFileChooser;
19 | import javax.swing.JFrame;
20 | import javax.swing.JPanel;
21 | public class MainUI extends JFrame implements ActionListener {
22 | /**
23 | *
24 | */
25 | private static final long serialVersionUID = 3570033620825245822L;
26 | public static final String PAINT_CMD = "Paint";
27 | public static final String SELECT_CMD = "Select Image...";
28 | private JButton paintBtn;
29 | private JButton selectBtn;
30 | private BufferedImage srcImage;
31 | private BufferedImage destImage;
32 | private JComponent imagePanel ;
33 | public MainUI()
34 | {
35 | super("Automatic Paintly Render - GloomyFish");
36 | initComponent();
37 | }
38 |
39 | private void initComponent() {
40 | imagePanel = new JComponent()
41 | {
42 | /**
43 | *
44 | */
45 | private static final long serialVersionUID = 1L;
46 |
47 | @Override
48 | protected void paintComponent(Graphics g) {
49 | g.clearRect(0, 0, getWidth(), getHeight());
50 | if(srcImage != null)
51 | {
52 | g.drawImage(srcImage, 0, 0, srcImage.getWidth(), srcImage.getHeight(), null);
53 | }
54 | if(destImage != null && srcImage != null)
55 | {
56 | g.drawImage(destImage, srcImage.getWidth() + 10, 0, destImage.getWidth(), destImage.getHeight(), null);
57 | }
58 | if(srcImage == null && destImage == null)
59 | {
60 | g.drawString("Please select your image...", 100, 200);
61 | }
62 | }
63 | };
64 | this.getContentPane().setLayout(new BorderLayout());
65 | this.getContentPane().add(imagePanel, BorderLayout.CENTER);
66 | paintBtn = new JButton(PAINT_CMD);
67 | selectBtn = new JButton(SELECT_CMD);
68 | JPanel btnPanel = new JPanel();
69 | btnPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
70 | btnPanel.add(selectBtn);
71 | btnPanel.add(paintBtn);
72 | this.getContentPane().add(btnPanel, BorderLayout.SOUTH);
73 | selectBtn.addActionListener(this);
74 | paintBtn.addActionListener(this);
75 | }
76 |
77 | public void openView()
78 | {
79 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
80 | java.net.URL imageURL = this.getClass().getResource("rainbow-fish-md.png");
81 | try {
82 | setIconImage(ImageIO.read(imageURL));
83 | } catch (IOException e) {
84 | System.err.println("An error occured when loading the image icon...");
85 | }
86 | this.setPreferredSize(new Dimension(800, 660));
87 | pack();
88 | centreView(this);
89 | setVisible(true);
90 | }
91 |
92 | public static void centreView(Window w) {
93 | Dimension me = w.getSize();
94 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
95 | int newX = (screenSize.width - me.width)/2;
96 | int newY = (screenSize.height - me.height)/2;
97 | w.setLocation(newX, newY);
98 | }
99 |
100 | public static void main(String[] args)
101 | {
102 | MainUI ui = new MainUI();
103 | ui.openView();
104 | }
105 |
106 | @Override
107 | public void actionPerformed(ActionEvent e) {
108 | String command = e.getActionCommand();
109 | System.out.println("Command : " + command);
110 | if(command.equals(SELECT_CMD))
111 | {
112 | JFileChooser chooser = new JFileChooser();
113 | chooser.showOpenDialog(null);
114 | File f = chooser.getSelectedFile();
115 | if(f == null) return;
116 | try {
117 | srcImage = ImageIO.read(f);
118 |
119 | } catch (IOException e1) {
120 | e1.printStackTrace();
121 | }
122 | this.repaint();
123 | }
124 | else if(command.equals(PAINT_CMD))
125 | {
126 | // stroke area
127 | StrokePaintlyMain spm = new StrokePaintlyMain(this);
128 | destImage = spm.filter(srcImage, null);
129 | this.repaint();
130 | }
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/src/com/book/chapter/fourteen/MomentsUtil.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.fourteen;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.util.Arrays;
5 |
6 | public class MomentsUtil {
7 | private static final double d02 = 250*250;
8 | public static int[] getRoi(int[] scaledInput, int xc, int yc, int width, int height, int sw, int sh, int[] wh) {
9 | int x0 = xc - width/2;
10 | int y0 = yc - height/2;
11 | /* adjust region to fit in source image */
12 | if (x0 < 0) {
13 | width += x0;
14 | x0 = 0;
15 | }
16 | if (x0 > width) x0 = width;
17 | if (y0 < 0) {
18 | height += y0;
19 | y0 = 0;
20 | }
21 | if (y0 > height) y0 = height;
22 | if ((x0 + width) > sw) {
23 | width = sw - x0;
24 | }
25 | if ((y0 + height) > sh){
26 | height = sh - y0;
27 | }
28 | wh[0] = width;
29 | wh[1] = height;
30 | int[] roi = new int[width * height];
31 | int rr = 0;
32 | int cc = 0;
33 | for(int row=y0; row<(y0 + height); row++)
34 | {
35 | cc = 0;
36 | for(int col= x0; col < (x0+width); col++)
37 | {
38 | int index = row * sw + col;
39 | roi[rr*width + cc] = scaledInput[index];
40 | cc++;
41 | }
42 | rr++;
43 | }
44 | return roi;
45 | }
46 |
47 | public static void calculateMoments(int[] roiArea, int[] xyrgb, double[] mms, int width, int height)
48 | {
49 | int y, x;
50 | int[] outPixels = colorDiff(roiArea, xyrgb, width, height);
51 | Arrays.fill(mms, 0);
52 | int index = 0;
53 | // *m00 = *m01 = *m10 = *m11 = *m02 = *m20 = 0;
54 |
55 | for (y = 0; y > 16) & 0xff;
91 | rgb[1] = (pixels[index] >> 8) & 0xff;
92 | rgb[2] = pixels[index] & 0xff;
93 | return rgb;
94 | }
95 | //mom_I
96 | public static double colorDiff(int[] rgb1, int[] rgb2)
97 | {
98 | // (1-(d/d0)^2)^2
99 | double d2, r2;
100 | d2 = colorDistance (rgb1, rgb2);
101 |
102 | if (d2 >= d02)
103 | return 0.0;
104 |
105 | r2 = d2 / d02;
106 |
107 | return ((1.0d - r2) * (1.0d - r2));
108 | }
109 |
110 | public static double colorDistance(int[] rgb1, int[] rgb2)
111 | {
112 | int dr, dg, db;
113 | dr = rgb1[0] - rgb2[0];
114 | dg = rgb1[1] - rgb2[1];
115 | db = rgb1[2] - rgb2[2];
116 | return dr * dr + dg * dg + db * db;
117 | }
118 |
119 | /**
120 | * A convenience method for getting ARGB pixels from an image. This tries to avoid the performance
121 | * penalty of BufferedImage.getRGB unmanaging the image.
122 | */
123 | public static int[] getRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
124 | int type = image.getType();
125 | if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
126 | return (int [])image.getRaster().getDataElements( x, y, width, height, pixels );
127 | return image.getRGB( x, y, width, height, pixels, 0, width );
128 | }
129 |
130 | /**
131 | * A convenience method for setting ARGB pixels in an image. This tries to avoid the performance
132 | * penalty of BufferedImage.setRGB unmanaging the image.
133 | */
134 | public static void setRGB( BufferedImage image, int x, int y, int width, int height, int[] pixels ) {
135 | int type = image.getType();
136 | if ( type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB )
137 | image.getRaster().setDataElements( x, y, width, height, pixels );
138 | else
139 | image.setRGB( x, y, width, height, pixels, 0, width );
140 | }
141 | public static int clamp(int p) {
142 | return p > 255 ? 255 : (p < 0 ? 0: p);
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/src/com/book/chapter/fourteen/StrokeAreaFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.fourteen;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.awt.image.ColorModel;
5 |
6 | import com.book.chapter.four.AbstractBufferedImageOp;
7 |
8 | public class StrokeAreaFilter extends AbstractBufferedImageOp {
9 |
10 | // default value, optional value 30, 15, 10, 5, 2
11 | private double size = 10;
12 | private static double d02 = 150*150;
13 | public StrokeAreaFilter() {
14 | }
15 |
16 | public double getSize() {
17 | return size;
18 | }
19 |
20 | public void setSize(double size) {
21 | this.size = size;
22 | }
23 |
24 | public StrokeAreaFilter(int strokeSize) {
25 | this.size = strokeSize;
26 | }
27 |
28 | public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
29 | int height = src.getHeight();
30 | int width = src.getWidth();
31 | // System.out.println("create custom white background color image...");
32 | BufferedImage whiteImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
33 | int[] outPixels = new int[width*height];
34 | int index = 0;
35 | for(int row=0; row> 24) & 0xff;
75 | rgb[0] = (inPixels[index] >> 16) & 0xff;
76 | rgb[1] = (inPixels[index] >> 8) & 0xff;
77 | rgb[2] = inPixels[index] & 0xff;
78 |
79 | /* adjust region to fit in source image */
80 | // color difference and moment Image
81 | double moment = 0.0d;
82 | for(int subRow = -semiRow; subRow <= semiRow; subRow++) {
83 | for(int subCol = -semiCol; subCol <= semiCol; subCol++) {
84 | newY = row + subRow;
85 | newX = col + subCol;
86 | if(newY < 0) {
87 | newY = 0;
88 | }
89 | if(newX < 0) {
90 | newX = 0;
91 | }
92 | if(newY >= height) {
93 | newY = height-1;
94 | }
95 | if(newX >= width) {
96 | newX = width - 1;
97 | }
98 | index2 = newY * width + newX;
99 | rgb2[0] = (inPixels[index2] >> 16) & 0xff; // red
100 | rgb2[1] = (inPixels[index2] >> 8) & 0xff; // green
101 | rgb2[2] = inPixels[index2] & 0xff; // blue
102 | moment += colorDiff(rgb, rgb2);
103 | }
104 | }
105 | // calculate the output pixel value.
106 | int outPixelValue = clamp((int) (255.0d * moment / (size*size)));
107 | outPixels[index] = (ta << 24) | (outPixelValue << 16) | (outPixelValue << 8) | outPixelValue;
108 | }
109 | }
110 |
111 | setRGB( dest, 0, 0, width, height, outPixels );
112 | return dest;
113 | }
114 |
115 | // public static int clamp(int p) {
116 | // return p > 255 ? 255 : (p < 0 ? 0: p);
117 | // }
118 |
119 | public static double colorDiff(int[] rgb1, int[] rgb2)
120 | {
121 | // (1-(d/d0)^2)^2
122 | double d2, r2;
123 | d2 = colorDistance (rgb1, rgb2);
124 |
125 | if (d2 >= d02)
126 | return 0.0;
127 |
128 | r2 = d2 / d02;
129 |
130 | return ((1.0d - r2) * (1.0d - r2));
131 | }
132 |
133 | public static double colorDistance(int[] rgb1, int[] rgb2)
134 | {
135 | int dr, dg, db;
136 | dr = rgb1[0] - rgb2[0];
137 | dg = rgb1[1] - rgb2[1];
138 | db = rgb1[2] - rgb2[2];
139 | return dr * dr + dg * dg + db * db;
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/src/com/book/chapter/fourteen/StrokeElement.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.fourteen;
2 |
3 | public class StrokeElement /*implements Comparable*/ {
4 | public int getXc() {
5 | return xc;
6 | }
7 | public void setXc(int xc) {
8 | this.xc = xc;
9 | }
10 | public int getYc() {
11 | return yc;
12 | }
13 | public void setYc(int yc) {
14 | this.yc = yc;
15 | }
16 | public float getW() {
17 | return w;
18 | }
19 | public void setW(float w) {
20 | this.w = w;
21 | }
22 | public float getL() {
23 | return l;
24 | }
25 | public void setL(float l) {
26 | this.l = l;
27 | }
28 | public int getLevel() {
29 | return level;
30 | }
31 | public void setLevel(int level) {
32 | this.level = level;
33 | }
34 | public float getTheta() {
35 | return theta;
36 | }
37 | public void setTheta(float theta) {
38 | this.theta = theta;
39 | }
40 | public int[] getRgb() {
41 | return rgb;
42 | }
43 | public void setRgb(int[] rgb) {
44 | this.rgb = rgb;
45 | }
46 |
47 | public StrokeElement(int xc, int yc, float w, float l, int level, float theta, int[] rgb)
48 | {
49 | this.xc = xc;
50 | this.yc = yc;
51 | this.w = w;
52 | this.l = l;
53 | this.level = level;
54 | this.theta = theta;
55 | this.rgb = rgb;
56 | }
57 |
58 | private int xc;
59 | private int yc;
60 | private float w;
61 | private float l;
62 | private int level;
63 | private float theta;
64 | private int[] rgb;
65 |
66 | public float getD() {
67 | float d1 = l * w;
68 | return d1;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/com/book/chapter/fourteen/StrokePaintlyMain.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/fourteen/StrokePaintlyMain.java
--------------------------------------------------------------------------------
/src/com/book/chapter/fourteen/rainbow-fish-md.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/fourteen/rainbow-fish-md.png
--------------------------------------------------------------------------------
/src/com/book/chapter/fourteen/stroke.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/fourteen/stroke.png
--------------------------------------------------------------------------------
/src/com/book/chapter/nine/CannyEdgeFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/nine/CannyEdgeFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/nine/GradientEdgeFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/nine/GradientEdgeFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/nine/LaplacianFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/nine/LaplacianFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/nine/RobotFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/nine/RobotFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/nine/SobolPrewittEdgeDetector.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/nine/SobolPrewittEdgeDetector.java
--------------------------------------------------------------------------------
/src/com/book/chapter/nine/cameraman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/nine/cameraman.png
--------------------------------------------------------------------------------
/src/com/book/chapter/one/AMERSN.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/one/AMERSN.ttf
--------------------------------------------------------------------------------
/src/com/book/chapter/one/CustomJPanel.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/one/CustomJPanel.java
--------------------------------------------------------------------------------
/src/com/book/chapter/one/FontDemo.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/one/FontDemo.java
--------------------------------------------------------------------------------
/src/com/book/chapter/one/GeneralPathDemo.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/one/GeneralPathDemo.java
--------------------------------------------------------------------------------
/src/com/book/chapter/one/JAVA2DDemo.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/one/JAVA2DDemo.java
--------------------------------------------------------------------------------
/src/com/book/chapter/one/StrokeDemo.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/one/StrokeDemo.java
--------------------------------------------------------------------------------
/src/com/book/chapter/one/TaijiDemo.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.one;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Color;
5 | import java.awt.Dimension;
6 | import java.awt.Graphics;
7 | import java.awt.Graphics2D;
8 | import java.awt.RenderingHints;
9 | import java.awt.Shape;
10 | import java.awt.geom.Area;
11 | import java.awt.geom.Ellipse2D;
12 | import java.awt.geom.Rectangle2D;
13 |
14 | import javax.swing.JFrame;
15 | import javax.swing.JPanel;
16 |
17 | public class TaijiDemo extends JPanel {
18 | /**
19 | *
20 | */
21 | private static final long serialVersionUID = 1L;
22 |
23 | public TaijiDemo()
24 | {
25 | super();
26 | }
27 |
28 | protected void paintComponent(Graphics g) {
29 | Graphics2D g2 = (Graphics2D)g;
30 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
31 | RenderingHints.VALUE_ANTIALIAS_ON);
32 | Shape lefthalfCirle = new Ellipse2D.Double(10,10, 300,300); // R = 150
33 | Shape righthalfCircle = new Ellipse2D.Double(10,10, 300,300); // R = 150
34 | Shape innerCircle1 = new Ellipse2D.Double(85,10, 150,150); // R/2 = 75
35 | Shape innerCircle2 = new Ellipse2D.Double(85,160, 150,150); // R = 150
36 |
37 | Shape rectangel1 = new Rectangle2D.Double(160, 10, 150, 300);
38 | Shape rectangel2 = new Rectangle2D.Double(10, 10, 150, 300);
39 |
40 | Area left = new Area(lefthalfCirle);
41 | Area right = new Area(righthalfCircle);
42 |
43 | Area area11 = new Area(rectangel1);
44 | Area area22 = new Area(rectangel2);
45 |
46 | left.subtract(area11);
47 | right.subtract(area22);
48 |
49 | Area inner1 = new Area(innerCircle1);
50 | Area inner2 = new Area(innerCircle2);
51 |
52 | left.add(inner1);
53 | right.add(inner2);
54 |
55 | // trick is here !!!
56 | right.subtract(inner1);
57 |
58 |
59 | // create minor circle here!!!
60 | Shape minorWhiteCircle = new Ellipse2D.Double(150,70, 20,20); // ++ 60
61 | Shape innerBlackCircle = new Ellipse2D.Double(150,230, 20,20); // R = 150
62 |
63 | // draw two big frame shape here...
64 | g2.setPaint(Color.WHITE);
65 | g2.fill(left);
66 | g2.setPaint(Color.BLACK);
67 | g2.fill(right);
68 |
69 | // draw minor circle here!!!
70 | g2.fill(minorWhiteCircle);
71 | g2.setPaint(Color.WHITE);
72 | g2.fill(innerBlackCircle);
73 | }
74 |
75 | public static void main(String[] args)
76 | {
77 | JFrame ui = new JFrame("Demo Graphics");
78 | ui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
79 | ui.getContentPane().setLayout(new BorderLayout());
80 | ui.getContentPane().add(new TaijiDemo(), BorderLayout.CENTER);
81 | ui.setPreferredSize(new Dimension(380, 380));
82 | ui.pack();
83 | ui.setVisible(true);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/com/book/chapter/one/lena.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/one/lena.jpg
--------------------------------------------------------------------------------
/src/com/book/chapter/seven/BicubicSharpenFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/seven/BicubicSharpenFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/seven/BicubicZoomFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/seven/BicubicZoomFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/seven/BilinearZoomFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/seven/BilinearZoomFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/seven/FastRotateFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/seven/FastRotateFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/seven/LanczosZoomFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.seven;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.awt.image.ColorModel;
5 |
6 | import com.book.chapter.four.AbstractBufferedImageOp;
7 |
8 | public class LanczosZoomFilter extends AbstractBufferedImageOp {
9 | // lanczos_size
10 | private float lanczosSize;
11 | private float destWidth;
12 |
13 | public LanczosZoomFilter() {
14 | lanczosSize = 3;
15 | destWidth = 100;
16 | }
17 |
18 | public LanczosZoomFilter(float lobes, int width) {
19 | this.lanczosSize = lobes;
20 | this.destWidth = width;
21 | }
22 |
23 | public void setLanczosSize(float size) {
24 | this.lanczosSize = size;
25 | }
26 |
27 | public void setDestWidth(float destWidth) {
28 | this.destWidth = destWidth;
29 | }
30 |
31 | @Override
32 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
33 | int width = src.getWidth();
34 | int height = src.getHeight();
35 | float ratio = width / this.destWidth;
36 | float rcp_ratio = 2.0f / ratio;
37 | float range2 = (float) Math.ceil(ratio * lanczosSize / 2);
38 |
39 | // destination image
40 | int dh = (int) (height * (this.destWidth / width));
41 | int dw = (int) this.destWidth;
42 |
43 | if (dest == null) {
44 | ColorModel cMD = src.getColorModel();
45 | dest = new BufferedImage(src.getColorModel(),
46 | cMD.createCompatibleWritableRaster(dw, dh),
47 | cMD.isAlphaPremultiplied(), null);
48 | }
49 |
50 | int[] inPixels = new int[width * height];
51 | int[] outPixels = new int[dw * dh];
52 |
53 | getRGB(src, 0, 0, width, height, inPixels);
54 | int index = 0;
55 | float fcy = 0, icy = 0, fcx = 0, icx = 0;
56 | for (int row = 0; row < dh; row++) {
57 | int ta = 0, tr = 0, tg = 0, tb = 0;
58 | fcy = (row + 0.5f) * ratio;
59 | icy = (float) Math.floor(fcy);
60 | for (int col = 0; col < dw; col++) {
61 | fcx = (col + 0.5f) * ratio;
62 | icx = (float) Math.floor(fcx);
63 |
64 | float sumred = 0, sumgreen = 0, sumblue = 0;
65 | float totalWeight = 0;
66 | for (int subcol = (int) (icx - range2);
67 | subcol <= icx + range2; subcol++) {
68 | if (subcol < 0 || subcol >= width)
69 | continue;
70 | int ncol = (int) Math.floor(1000 *
71 | Math.abs(subcol - fcx));
72 |
73 | for (int subrow = (int) (icy - range2);
74 | subrow <= icy + range2; subrow++) {
75 | if (subrow < 0 || subrow >= height)
76 | continue;
77 | int nrow = (int) Math.floor(1000 *
78 | Math.abs(subrow - fcy));
79 | float weight = (float) getLanczosFactor(
80 | Math.sqrt(Math
81 | .pow(ncol * rcp_ratio, 2)
82 | + Math.pow(nrow * rcp_ratio, 2)) / 1000);
83 | if (weight > 0) {
84 | index = (subrow * width + subcol);
85 | tr = (inPixels[index] >> 16) & 0xff;
86 | tg = (inPixels[index] >> 8) & 0xff;
87 | tb = inPixels[index] & 0xff;
88 | totalWeight += weight;
89 | sumred += weight * tr;
90 | sumgreen += weight * tg;
91 | sumblue += weight * tb;
92 | }
93 | }
94 | }
95 | index = row * dw + col;
96 | tr = (int) (sumred / totalWeight);
97 | tg = (int) (sumgreen / totalWeight);
98 | tb = (int) (sumblue / totalWeight);
99 | outPixels[index] = (255 << 24) | (clamp(tr) << 16)
100 | | (clamp(tg) << 8) | clamp(tb);
101 |
102 | // clear for next pixel
103 | sumred = 0;
104 | sumgreen = 0;
105 | sumblue = 0;
106 | totalWeight = 0;
107 |
108 | }
109 | }
110 | setRGB(dest, 0, 0, dw, dh, outPixels);
111 | return dest;
112 | }
113 |
114 | private double getLanczosFactor(double distance) {
115 | if (distance > lanczosSize)
116 | return 0;
117 | distance *= Math.PI;
118 | if (Math.abs(distance) < 1e-16)
119 | return 1;
120 | double xx = distance / lanczosSize;
121 | return Math.sin(distance) * Math.sin(xx) / distance / xx;
122 | }
123 |
124 | }
--------------------------------------------------------------------------------
/src/com/book/chapter/seven/NearestZoomFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.seven;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.awt.image.ColorModel;
5 |
6 | import com.book.chapter.four.AbstractBufferedImageOp;
7 |
8 | public class NearestZoomFilter extends AbstractBufferedImageOp {
9 |
10 | private int destH; // zoom height
11 | private int destW; // zoom width
12 |
13 | public NearestZoomFilter()
14 | {
15 | System.out.println("Nearest Pixel Interpolation Algo");
16 | }
17 |
18 | public void setDestHeight(int destH) {
19 | this.destH = destH;
20 | }
21 |
22 | public void setDestWidth(int destW) {
23 | this.destW = destW;
24 | }
25 |
26 | @Override
27 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
28 | int width = src.getWidth();
29 | int height = src.getHeight();
30 |
31 | if (dest == null)
32 | dest = createCompatibleDestImage(src, null);
33 |
34 | int[] inPixels = new int[width * height];
35 | int[] outPixels = new int[destH * destW];
36 | getRGB(src, 0, 0, width, height, inPixels);
37 | float rowRatio = ((float)height)/((float)destH);
38 | float colRatio = ((float)width)/((float)destW);
39 | int index = 0;
40 | for (int row = 0; row < destH; row++) {
41 | int srcRow = Math.round(((float)row)*rowRatio);
42 | if(srcRow >=height) {
43 | srcRow = height - 1;
44 | }
45 | for (int col = 0; col < destW; col++) {
46 | int srcCol = Math.round(((float)col)*colRatio);
47 | if(srcCol >= width) {
48 | srcCol = width - 1;
49 | }
50 | int index2 = row * destW + col;
51 | index = srcRow * width + srcCol;
52 | outPixels[index2] = inPixels[index];
53 | }
54 | }
55 | setRGB(dest, 0, 0, destW, destH, outPixels);
56 | return dest;
57 | }
58 |
59 | public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
60 | if ( dstCM == null )
61 | dstCM = src.getColorModel();
62 | return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(destW, destH), dstCM.isAlphaPremultiplied(), null);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/com/book/chapter/seven/XShearFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.seven;
2 |
3 | import java.awt.Color;
4 | import java.awt.image.BufferedImage;
5 | import java.awt.image.ColorModel;
6 |
7 | import com.book.chapter.four.AbstractBufferedImageOp;
8 |
9 | public class XShearFilter extends AbstractBufferedImageOp {
10 | private int outw;
11 | private int outh;
12 | private double angle;
13 | private Color backgroundColor;
14 |
15 | public XShearFilter()
16 | {
17 | backgroundColor = Color.BLACK;
18 | this.angle = 45;
19 | }
20 |
21 | public int getOutw() {
22 | return outw;
23 | }
24 | public void setOutw(int outw) {
25 | this.outw = outw;
26 | }
27 | public int getOuth() {
28 | return outh;
29 | }
30 | public void setOuth(int outh) {
31 | this.outh = outh;
32 | }
33 | public double getAngle() {
34 | return angle;
35 | }
36 | public void setAngle(double angle) {
37 | this.angle = angle;
38 | }
39 | public Color getBackgroundColor() {
40 | return backgroundColor;
41 | }
42 | public void setBackgroundColor(Color backgroundColor) {
43 | this.backgroundColor = backgroundColor;
44 | }
45 | @Override
46 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
47 | int width = src.getWidth();
48 | int height = src.getHeight();
49 |
50 | double angleValue = ((angle)/180.0d) * Math.PI;
51 | outh = height;
52 | outw = (int)(width + height * Math.tan(angleValue));
53 | System.out.println("after shear, new width : " + outw);
54 | System.out.println("after shear, new height: " + outh);
55 |
56 | int[] inPixels = new int[width*height];
57 | int[] outPixels = new int[outh*outw];
58 | getRGB( src, 0, 0, width, height, inPixels );
59 | int index = 0;
60 | for(int row=0; row= height) {
82 | return new int[]{backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()};
83 | }
84 | if(col < 0 || col >= width) {
85 | return new int[]{backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()};
86 | }
87 | double u = pcol - col;
88 | int nextCol = (int)(col + 1);
89 | if((col + 1) >= width) {
90 | nextCol = (int)col;
91 | }
92 | int index1 = (int)(row * width + col);
93 | int index2 = (int)(row * width + nextCol);
94 |
95 | int tr1, tr2;
96 | int tg1, tg2;
97 | int tb1, tb2;
98 |
99 | tr1 = (input[index1] >> 16) & 0xff;
100 | tg1 = (input[index1] >> 8) & 0xff;
101 | tb1 = input[index1] & 0xff;
102 |
103 | tr2 = (input[index2] >> 16) & 0xff;
104 | tg2 = (input[index2] >> 8) & 0xff;
105 | tb2 = input[index2] & 0xff;
106 |
107 | int tr = (int)(tr1 * (1-u) + tr2 * u);
108 | int tg = (int)(tg1 * (1-u) + tg2 * u);
109 | int tb = (int)(tb1 * (1-u) + tb2 * u);
110 |
111 | return new int[]{tr, tg, tb};
112 | }
113 |
114 | public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
115 | if ( dstCM == null )
116 | dstCM = src.getColorModel();
117 | return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(outw, outh), dstCM.isAlphaPremultiplied(), null);
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/src/com/book/chapter/seven/YShearFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.seven;
2 |
3 | import java.awt.Color;
4 | import java.awt.image.BufferedImage;
5 | import java.awt.image.ColorModel;
6 |
7 | import com.book.chapter.four.AbstractBufferedImageOp;
8 |
9 | public class YShearFilter extends AbstractBufferedImageOp {
10 |
11 | private int outw;
12 | private int outh;
13 | private int srcWidth;
14 | private double angle;
15 | private Color backgroundColor;
16 |
17 | public YShearFilter()
18 | {
19 | backgroundColor = Color.BLACK;
20 | }
21 |
22 | public void setAngle(double angle) {
23 | this.angle = angle;
24 | }
25 |
26 | public void setSrcWidth(int width)
27 | {
28 | this.srcWidth = width;
29 | }
30 |
31 | public void setBackgroundColor(Color backgroundColor) {
32 | this.backgroundColor = backgroundColor;
33 | }
34 |
35 | @Override
36 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
37 | int width = src.getWidth();
38 | int height = src.getHeight();
39 |
40 | double angleValue = ((angle)/180.0d) * Math.PI;
41 | outw = width;
42 | outh = (int)(srcWidth * Math.sin(angleValue) + height * Math.cos(angleValue));// big trick!!!!
43 | int outhh = (int)(srcWidth * Math.sin(angleValue) + height);// big trick!!!!
44 | int deltaY = (outh - height);
45 | int ddy = outhh - outh;
46 | System.out.println("after shear, new width : " + outw);
47 | System.out.println("after shear, new height: " + outh);
48 | System.out.println("deltaY = " + deltaY);
49 | int[] inPixels = new int[width*height];
50 | int[] outPixels = new int[outh*outw];
51 | getRGB( src, 0, 0, width, height, inPixels);
52 | int index = 0;
53 | for(int row=0; row= height) {
76 | return new int[]{backgroundColor.getRed(),
77 | backgroundColor.getGreen(),
78 | backgroundColor.getBlue()};
79 | }
80 | if(col < 0 || col >= width) {
81 | return new int[]{backgroundColor.getRed(),
82 | backgroundColor.getGreen(),
83 | backgroundColor.getBlue()};
84 | }
85 | double u = prow - row;
86 | int nextRow = (int)(row + 1);
87 | if((row + 1) >= height) {
88 | nextRow = (int)row;
89 | }
90 | int index1 = (int)(row * width + col);
91 | int index2 = (int)(nextRow * width + col);
92 |
93 | int tr1, tr2;
94 | int tg1, tg2;
95 | int tb1, tb2;
96 |
97 | tr1 = (input[index1] >> 16) & 0xff;
98 | tg1 = (input[index1] >> 8) & 0xff;
99 | tb1 = input[index1] & 0xff;
100 |
101 | tr2 = (input[index2] >> 16) & 0xff;
102 | tg2 = (input[index2] >> 8) & 0xff;
103 | tb2 = input[index2] & 0xff;
104 |
105 | int tr = (int)(tr1 * (1-u) + tr2 * u);
106 | int tg = (int)(tg1 * (1-u) + tg2 * u);
107 | int tb = (int)(tb1 * (1-u) + tb2 * u);
108 |
109 | return new int[]{tr, tg, tb};
110 | }
111 |
112 | public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dstCM) {
113 | if ( dstCM == null )
114 | dstCM = src.getColorModel();
115 | return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(outw, outh), dstCM.isAlphaPremultiplied(), null);
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/src/com/book/chapter/six/BinaryFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.six;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import com.book.chapter.four.AbstractBufferedImageOp;
8 |
9 | public class BinaryFilter extends AbstractBufferedImageOp {
10 | public final static int MEAN_THRESHOLD = 2;
11 | public final static int SHIFT_THRESHOLD = 4;
12 |
13 | private int thresholdType;
14 |
15 | public BinaryFilter() {
16 | thresholdType = SHIFT_THRESHOLD;
17 | }
18 |
19 | public int getThresholdType() {
20 | return thresholdType;
21 | }
22 |
23 | public void setThresholdType(int thresholdType) {
24 | this.thresholdType = thresholdType;
25 | }
26 |
27 | @Override
28 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
29 | int width = src.getWidth();
30 | int height = src.getHeight();
31 |
32 | if (dest == null)
33 | dest = createCompatibleDestImage(src, null);
34 |
35 | int[] inPixels = new int[width * height];
36 | int[] outPixels = new int[width * height];
37 | getRGB(src, 0, 0, width, height, inPixels);
38 | int index = 0;
39 | int means = (int) getThreshold(inPixels, height, width);
40 | for (int row = 0; row < height; row++) {
41 | int ta = 0, tr = 0, tg = 0, tb = 0;
42 | for (int col = 0; col < width; col++) {
43 | index = row * width + col;
44 | ta = (inPixels[index] >> 24) & 0xff;
45 | tr = (inPixels[index] >> 16) & 0xff;
46 | tg = (inPixels[index] >> 8) & 0xff;
47 | tb = inPixels[index] & 0xff;
48 | if (tr > means) {
49 | tr = tg = tb = 255; // white
50 | } else {
51 | tr = tg = tb = 0; // black
52 | }
53 | outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;
54 | }
55 | }
56 | setRGB(dest, 0, 0, width, height, outPixels);
57 | return dest;
58 | }
59 |
60 | private double getThreshold(int[] pixels, int width, int height) {
61 | int index = 0;
62 | double mean = 0;
63 | if (thresholdType == MEAN_THRESHOLD) {
64 | // calculate mean, MAX, MIN
65 | int max = 0;
66 | int min = 255;
67 | double sum = 0.0;
68 | for (int row = 0; row < height; row++) {
69 | int tr = 0;
70 | for (int col = 0; col < width; col++) {
71 | index = row * width + col;
72 | tr = (pixels[index] >> 16) & 0xff;
73 | min = Math.min(min, tr);
74 | max = Math.max(max, tr);
75 | sum += tr;
76 | }
77 | }
78 | mean = sum / (width * height);
79 | } else if (thresholdType == SHIFT_THRESHOLD) {
80 | mean = getMeanShiftThreshold(pixels, height, width);
81 | }
82 | return mean;
83 | }
84 |
85 | private static int getMeans(List data) {
86 | int result = 0;
87 | int size = data.size();
88 | for (Integer i : data) {
89 | result += i;
90 | }
91 | return (result / size);
92 | }
93 |
94 | private int getMeanShiftThreshold(int[] inPixels, int height, int width) {
95 | // maybe this value can reduce the calculation consume;
96 | int inithreshold = 127;
97 | int finalthreshold = 0;
98 | int temp[] = new int[inPixels.length];
99 | for (int index = 0; index < inPixels.length; index++) {
100 | temp[index] = (inPixels[index] >> 16) & 0xff;
101 | }
102 | List sub1 = new ArrayList();
103 | List sub2 = new ArrayList();
104 | int means1 = 0, means2 = 0;
105 | while (finalthreshold != inithreshold) {
106 | finalthreshold = inithreshold;
107 | for (int i = 0; i < temp.length; i++) {
108 | if (temp[i] <= inithreshold) {
109 | sub1.add(temp[i]);
110 | } else {
111 | sub2.add(temp[i]);
112 | }
113 | }
114 | means1 = getMeans(sub1);
115 | means2 = getMeans(sub2);
116 | sub1.clear();
117 | sub2.clear();
118 | inithreshold = (means1 + means2) / 2;
119 | }
120 | long start = System.currentTimeMillis();
121 | System.out.println("Final threshold = " + finalthreshold);
122 | long endTime = System.currentTimeMillis() - start;
123 | System.out.println("Time consumes : " + endTime);
124 | return finalthreshold;
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/src/com/book/chapter/six/HistogramComparisonFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/six/HistogramComparisonFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/six/HistogramDataExtractor.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.six;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class HistogramDataExtractor extends AbstractBufferedImageOp {
8 | private int threshold = -1;
9 | public void setThreshold(int threshold) {
10 | this.threshold = threshold;
11 | }
12 |
13 | private int[] histogram;
14 |
15 | public int[] getHistogram() {
16 | return histogram;
17 | }
18 |
19 | public void setHistogram(int[] histogram) {
20 | this.histogram = histogram;
21 | }
22 |
23 | @Override
24 | public BufferedImage filter(BufferedImage src,
25 | BufferedImage dest) {
26 | int width = src.getWidth();
27 | int height = src.getHeight();
28 |
29 | if (dest == null)
30 | dest = createCompatibleDestImage(src, null);
31 |
32 | int[] inPixels = new int[width * height];
33 | getRGB(src, 0, 0, width, height, inPixels);
34 | int index = 0;
35 |
36 | // get histogram data
37 | histogram = new int[256];
38 | for(int i=0; i> 16) & 0xff;
47 | histogram[tr]++;
48 | }
49 | }
50 |
51 | if(threshold > 0)
52 | {
53 | // binary image
54 | int[] outPixels = new int[width*height];
55 | for(int row=0; row> 24) & 0xff;
60 | tr = (inPixels[index] >> 16) & 0xff;
61 | tg = (inPixels[index] >> 8) & 0xff;
62 | tb = inPixels[index] & 0xff;
63 | if(tr >=threshold) {
64 | tr = tg = tb = 255;
65 | } else {
66 | tr = tg = tb = 0;
67 | }
68 | outPixels[index] = (ta << 24) | (tr << 16)
69 | | (tg << 8) | tb;
70 | }
71 | }
72 | setRGB( dest, 0, 0, width, height, outPixels );
73 | }
74 | return dest;
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/src/com/book/chapter/six/HistogramEFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/six/HistogramEFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/six/HistogramFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.six;
2 |
3 | import java.awt.Color;
4 | import java.awt.Graphics2D;
5 | import java.awt.geom.Rectangle2D;
6 | import java.awt.image.BufferedImage;
7 |
8 | import com.book.chapter.four.AbstractBufferedImageOp;
9 |
10 | public class HistogramFilter extends AbstractBufferedImageOp {
11 |
12 | @Override
13 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
14 | int width = src.getWidth();
15 | int height = src.getHeight();
16 |
17 | if (dest == null)
18 | dest = createCompatibleDestImage(src, null);
19 |
20 | int[] inPixels = new int[width * height];
21 | getRGB(src, 0, 0, width, height, inPixels);
22 | int index = 0;
23 | // get histogram data
24 | int[] histogram = new int[256];
25 | for(int i=0; i> 16) & 0xff;
34 | histogram[tr]++;
35 | }
36 | }
37 | double maxFrequency = 0;
38 | for(int i=0; i> 24) & 0xff;
41 | tr = (inPixels[index] >> 16) & 0xff;
42 | tg = (inPixels[index] >> 8) & 0xff;
43 | tb = inPixels[index] & 0xff;
44 | histogram[0][tr]++; // red
45 | histogram[1][tg]++; // green
46 | histogram[2][tb]++; // blue
47 | }
48 | }
49 | double[] maxRGBFrequency = new double[]{0,0,0};
50 | for(int i=0; i= 0)
39 | {
40 | callBack.mooveLine(endX);
41 |
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/com/book/chapter/six/ViewCallBack.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.six;
2 |
3 | public interface ViewCallBack {
4 |
5 | public void mooveLine(double position);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/com/book/chapter/six/blank.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/six/blank.jpg
--------------------------------------------------------------------------------
/src/com/book/chapter/six/emd/Feature.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.six.emd;
2 |
3 |
4 | public interface Feature {
5 | public double groundDist(Feature f);
6 | }
--------------------------------------------------------------------------------
/src/com/book/chapter/six/emd/Feature2D.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.six.emd;
2 |
3 | /**
4 | * @author Telmo Menezes (telmo@telmomenezes.com)
5 | *
6 | */
7 | public class Feature2D implements Feature {
8 | private double x;
9 | private double y;
10 |
11 | public Feature2D(double x, double y) {
12 | this.x = x;
13 | this.y = y;
14 | }
15 |
16 | public double groundDist(Feature f) {
17 | Feature2D f2d = (Feature2D)f;
18 | double deltaX = x - f2d.x;
19 | double deltaY = y - f2d.y;
20 | return Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/com/book/chapter/six/emd/Signature.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.six.emd;
2 | /**
3 | * @author Telmo Menezes (telmo@telmomenezes.com)
4 | *
5 | */
6 | public class Signature {
7 | private int numberOfFeatures;
8 | private Feature[] features;
9 | private double[] weights;
10 |
11 | public int getNumberOfFeatures() {
12 | return numberOfFeatures;
13 | }
14 |
15 | public void setNumberOfFeatures(int numberOfFeatures) {
16 | this.numberOfFeatures = numberOfFeatures;
17 | }
18 |
19 | public Feature[] getFeatures() {
20 | return features;
21 | }
22 |
23 | public void setFeatures(Feature[] features) {
24 | this.features = features;
25 | }
26 |
27 | public double[] getWeights() {
28 | return weights;
29 | }
30 |
31 | public void setWeights(double[] weights) {
32 | this.weights = weights;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/book/chapter/six/lena_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/six/lena_gray.png
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/AreaCenterFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/AreaCenterFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/AreaOrientationFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/AreaOrientationFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/BFSAlgorithm.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.ten;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | /**
8 | * Breath First Search for graphics
9 | * @author gloomyfish
10 | *
11 | */
12 | public class BFSAlgorithm {
13 | private List pixelList = null;
14 | private int grayLevel = 1;
15 | public int getGrayLevel() {
16 | return grayLevel;
17 | }
18 |
19 | public int getTotalOfLabels()
20 | {
21 | Map labelMap = new HashMap();
22 | for(PixelPoint p : pixelList)
23 | {
24 | if(p.getValue() >= grayLevel)
25 | {
26 | if(labelMap.containsKey(p.getLabel()))
27 | {
28 | Integer count = labelMap.get(p.getLabel());
29 | count += 1;
30 | labelMap.put(p.getLabel(), count);
31 | }
32 | else
33 | {
34 | labelMap.put(p.getLabel(), new Integer(1));
35 | }
36 | }
37 | }
38 | Integer[] keys = labelMap.keySet().toArray(new Integer[0]);
39 | for(Integer key : keys)
40 | {
41 | System.out.println("Label index : " + key);
42 | }
43 | System.out.println("total labels : " + labelMap.size());
44 | return labelMap.size();
45 | }
46 |
47 | public void setGrayLevel(int grayLevel) {
48 | this.grayLevel = grayLevel;
49 | }
50 |
51 | public BFSAlgorithm(List pixelList)
52 | {
53 | this.pixelList = pixelList;
54 | grayLevel = 1; // front color - target pixel
55 | }
56 |
57 | public void process()
58 | {
59 | if(this.pixelList == null) return;
60 | int label = 1;
61 | for(PixelPoint pp : pixelList)
62 | {
63 | if(pp.getValue() >= grayLevel)
64 | {
65 | if(pp.getStatus() == PixelPoint.UNMARKED)
66 | {
67 | pp.setStatus(PixelPoint.VISITED);
68 | pp.setLabel(label);
69 | MyQueue mq = new MyQueue(10000);
70 | for(PixelPoint npp : pp.getNeighbours())
71 | {
72 | if(npp.getStatus() == PixelPoint.UNMARKED && npp.getValue() >= grayLevel)
73 | {
74 | npp.setStatus(PixelPoint.MARKED);
75 | mq.enqueue(npp);
76 | }
77 | }
78 | while(!mq.isEmpty())
79 | {
80 | PixelPoint obj = (PixelPoint)mq.dequeue();
81 | if(obj.getStatus() == PixelPoint.MARKED)
82 | {
83 | obj.setLabel(label);
84 | obj.setStatus(PixelPoint.VISITED);
85 | }
86 | for(PixelPoint nnpp : obj.getNeighbours())
87 | {
88 | if(nnpp.getStatus() == PixelPoint.UNMARKED && nnpp.getValue() >= grayLevel)
89 | {
90 | nnpp.setStatus(PixelPoint.MARKED);
91 | mq.enqueue(nnpp);
92 | }
93 | }
94 | }
95 | label++;
96 | }
97 | }
98 | }
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/BinaryDitherFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/BinaryDitherFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/BinaryEdgeFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/BinaryEdgeFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/DFSAlgorithm.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.ten;
2 |
3 | import java.util.HashMap;
4 | import java.util.List;
5 | import java.util.Map;
6 |
7 | public class DFSAlgorithm {
8 |
9 | private List pixelList = null;
10 | private int grayLevel = 1;
11 | public int getGrayLevel() {
12 | return grayLevel;
13 | }
14 | public void setGrayLevel(int grayLevel) {
15 | this.grayLevel = grayLevel;
16 | }
17 | public DFSAlgorithm(List pixelList)
18 | {
19 | this.pixelList = pixelList;
20 | grayLevel = 0; // front color - target pixel
21 | }
22 |
23 | public void process()
24 | {
25 | if(this.pixelList == null) return;
26 | int label = 1;
27 | for(PixelPoint pp : pixelList)
28 | {
29 | if(pp.getValue() == grayLevel)
30 | {
31 | if(pp.getStatus() == PixelPoint.UNMARKED)
32 | {
33 | // initialization stack
34 | pp.setStatus(PixelPoint.MARKED);
35 | pp.setLabel(label);
36 | MyStack ms = new MyStack(4);
37 | MyStack markedPoint = new MyStack(4000);
38 | ms.push(pp);
39 |
40 | // Depth First Search
41 | while(!ms.isEmpty())
42 | {
43 | PixelPoint obj = (PixelPoint)ms.pop();
44 | markedPoint.push(obj);
45 | if(obj.getStatus() == PixelPoint.MARKED)
46 | {
47 | for(PixelPoint nnpp : obj.getNeighbours())
48 | {
49 | if(nnpp.getStatus() == PixelPoint.UNMARKED && nnpp.getValue() == grayLevel)
50 | {
51 | nnpp.setStatus(PixelPoint.MARKED);
52 | ms.push(nnpp);
53 | }
54 | }
55 | }
56 | }
57 |
58 | // tag label now!!
59 | while(!markedPoint.isEmpty())
60 | {
61 | PixelPoint obj = (PixelPoint)markedPoint.pop();
62 | obj.setLabel(label);
63 | obj.setStatus(PixelPoint.VISITED);
64 | }
65 | label++;
66 | }
67 | }
68 | }
69 | }
70 |
71 | public int getTotalOfLabels()
72 | {
73 | Map labelMap = new HashMap();
74 | for(PixelPoint p : pixelList)
75 | {
76 | if(p.getValue() == grayLevel)
77 | {
78 | if(labelMap.containsKey(p.getLabel()))
79 | {
80 | Integer count = labelMap.get(p.getLabel());
81 | count += 1;
82 | labelMap.put(p.getLabel(), count);
83 | }
84 | else
85 | {
86 | labelMap.put(p.getLabel(), new Integer(1));
87 | }
88 | }
89 | }
90 | Integer[] keys = labelMap.keySet().toArray(new Integer[0]);
91 | for(Integer key : keys)
92 | {
93 | System.out.println("Label index : " + key);
94 | }
95 | System.out.println("total labels : " + labelMap.size());
96 | return labelMap.size();
97 | }
98 |
99 |
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/FloodFillUI.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.ten;
2 |
3 | import java.awt.Color;
4 | import java.awt.Dimension;
5 | import java.awt.Graphics;
6 | import java.awt.Graphics2D;
7 | import java.awt.MediaTracker;
8 | import java.awt.event.MouseEvent;
9 | import java.awt.event.MouseListener;
10 | import java.awt.image.BufferedImage;
11 | import java.io.File;
12 | import java.io.IOException;
13 |
14 | import javax.imageio.ImageIO;
15 | import javax.swing.JComponent;
16 | import javax.swing.JFileChooser;
17 | import javax.swing.JFrame;
18 |
19 | public class FloodFillUI extends JComponent implements MouseListener{
20 |
21 | /**
22 | *
23 | */
24 | private static final long serialVersionUID = 1L;
25 | private BufferedImage rawImg;
26 | private MediaTracker tracker;
27 | private Dimension mySize;
28 | FloodFillAlgorithm ffa;
29 | public FloodFillUI(File f)
30 | {
31 | try {
32 | rawImg = ImageIO.read(f);
33 | } catch (IOException e1) {
34 | e1.printStackTrace();
35 | }
36 |
37 | tracker = new MediaTracker(this);
38 | tracker.addImage(rawImg, 1);
39 |
40 | // blocked 10 seconds to load the image data
41 | try {
42 | if (!tracker.waitForID(1, 10000)) {
43 | System.out.println("Load error.");
44 | System.exit(1);
45 | }// end if
46 | } catch (InterruptedException e) {
47 | e.printStackTrace();
48 | System.exit(1);
49 | }// end catch
50 |
51 | mySize = new Dimension(300, 300);
52 | this.addMouseListener(this);
53 | ffa = new FloodFillAlgorithm(rawImg);
54 | JFrame imageFrame = new JFrame("Flood File Algorithm Demo - Gloomyfish");
55 | imageFrame.getContentPane().add(this);
56 | imageFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
57 | imageFrame.pack();
58 | imageFrame.setVisible(true);
59 | }
60 |
61 | public void paint(Graphics g) {
62 | Graphics2D g2 = (Graphics2D) g;
63 | g2.drawImage(rawImg, 10, 10, rawImg.getWidth(), rawImg.getHeight(), null);
64 | }
65 | public Dimension getPreferredSize() {
66 | return mySize;
67 | }
68 |
69 | public Dimension getMinimumSize() {
70 | return mySize;
71 | }
72 |
73 | public Dimension getMaximumSize() {
74 | return mySize;
75 | }
76 |
77 | public static void main(String[] args) {
78 | JFileChooser chooser = new JFileChooser();
79 | chooser.showOpenDialog(null);
80 | File f = chooser.getSelectedFile();
81 | new FloodFillUI(f);
82 | }
83 |
84 | @Override
85 | public void mouseClicked(MouseEvent e) {
86 | System.out.println("Mouse Clicked Event!!");
87 | int x = (int)e.getPoint().getX();
88 | int y = (int)e.getPoint().getY();
89 | System.out.println("mouse location x = " + x); // column
90 | System.out.println("mouse location y = " + y); // row
91 | System.out.println();
92 | long startTime = System.nanoTime();
93 | // ffa.floodFill4(x, y, Color.GREEN.getRGB(), ffa.getColor(x, y));
94 | // ffa.floodFill8(x, y, Color.GREEN.getRGB(), ffa.getColor(x, y));
95 | // ffa.floodFillScanLine(x, y, Color.GREEN.getRGB(), ffa.getColor(x, y)); // 13439051
96 | ffa.floodFillScanLineWithStack(x, y, Color.GREEN.getRGB(), ffa.getColor(x, y)); // - 16660142
97 | long endTime = System.nanoTime() - startTime;
98 | System.out.println("run time = " + endTime);
99 | ffa.updateResult();
100 | this.repaint();
101 | }
102 |
103 | @Override
104 | public void mousePressed(MouseEvent e) {
105 | // TODO Auto-generated method stub
106 |
107 | }
108 |
109 | @Override
110 | public void mouseReleased(MouseEvent e) {
111 | // TODO Auto-generated method stub
112 |
113 | }
114 |
115 | @Override
116 | public void mouseEntered(MouseEvent e) {
117 | // TODO Auto-generated method stub
118 |
119 | }
120 |
121 | @Override
122 | public void mouseExited(MouseEvent e) {
123 | // TODO Auto-generated method stub
124 |
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/GeometricMomentsAlg.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.ten;
2 |
3 | public class GeometricMomentsAlg {
4 | private int BACKGROUND = 0; // background color
5 | private int labelIndex = 1;
6 |
7 | public GeometricMomentsAlg()
8 | {
9 | System.out.println("Geometric Moments Algorithm Initialziation...");
10 | }
11 |
12 | public int getLabelIndex() {
13 | return labelIndex;
14 | }
15 |
16 | public void setLabelIndex(int labelIndex) {
17 | this.labelIndex = labelIndex;
18 | }
19 |
20 | public int getBACKGROUND() {
21 | return BACKGROUND;
22 | }
23 |
24 | public void setBACKGROUND(int bACKGROUND) {
25 | BACKGROUND = bACKGROUND;
26 | }
27 |
28 | public double[] getGeometricCenterCoordinate(int[] pixels, int width, int height)
29 | {
30 | double m00 = moments(pixels, width, height, 0, 0);
31 | double xCr = moments(pixels, width, height, 1, 0) / m00; // row
32 | double yCr = moments(pixels, width, height, 0, 1) / m00; // column
33 | return new double[]{xCr, yCr};
34 | }
35 |
36 | public double moments(int[] pixels, int width, int height, int p, int q)
37 | {
38 | double mpq = 0.0;
39 | int index = 0;
40 | for(int row=0; row this.capticy)
43 | {
44 | throw new IllegalArgumentException("reach the max size of this queue ");
45 | }
46 | objectArray[last] = item;
47 | last++;
48 | }
49 |
50 | public boolean isEmpty()
51 | {
52 | return (numberOfItems == 0);
53 | }
54 |
55 | public int size()
56 | {
57 | return this.numberOfItems;
58 | }
59 |
60 | /**
61 | * First In First Out - Queue
62 | * @param args
63 | */
64 | public static void main(String[] args)
65 | {
66 | MyQueue mq = new MyQueue(10);
67 | mq.enqueue("aa");
68 | System.out.println(mq.dequeue().toString());
69 | mq.enqueue("bb");
70 | mq.enqueue("cc");
71 | mq.enqueue("dd");
72 | System.out.println(mq.dequeue().toString());
73 | System.out.println(mq.dequeue().toString());
74 | System.out.println(mq.dequeue().toString());
75 |
76 |
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/MyStack.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.ten;
2 |
3 |
4 | public class MyStack {
5 | private Object[] elementData;
6 | private int elementCount;
7 | private int capacityIncrement;
8 |
9 | public MyStack(int capacity)
10 | {
11 | if(capacity <= 0)
12 | {
13 | throw new java.lang.IllegalArgumentException("The value of capacity must be > 0 ");
14 | }
15 | this.capacityIncrement = capacity;
16 | elementData = new Object[capacityIncrement];
17 | }
18 |
19 | public boolean isEmpty()
20 | {
21 | return elementCount == 0;
22 | }
23 |
24 | public void clear()
25 | {
26 | elementData = null;
27 | elementCount = 0;
28 | }
29 |
30 | public void push(Object obj)
31 | {
32 | if(elementCount == elementData.length)
33 | {
34 | Object[] objects = new Object[elementData.length + capacityIncrement];
35 | System.arraycopy(elementData, 0, objects, 0, elementData.length);
36 | elementData = objects;
37 | }
38 | elementData[elementCount] = obj;
39 | elementCount++;
40 | }
41 |
42 | public void display()
43 | {
44 | for(int i=0; i {
7 | public final static int UNMARKED = -1;
8 | public final static int VISITED = 1;
9 | public final static int MARKED = 2;
10 | private int value;
11 | private int x; // col
12 | private int y; // row
13 | private int status;
14 | private int label;
15 | private int dist;
16 | private List neighbours = null;
17 |
18 | public PixelPoint(int row, int col, int pixel) {
19 | this.status = UNMARKED;
20 |
21 | this.value = pixel;
22 | this.x = col;
23 | this.y = row;
24 | this.dist = 0;
25 | }
26 |
27 | public int getValue() {
28 | return value;
29 | }
30 |
31 | public void setValue(int value) {
32 | this.value = value;
33 | }
34 |
35 | public int getX() {
36 | return x;
37 | }
38 |
39 | public void setX(int x) {
40 | this.x = x;
41 | }
42 |
43 | public int getY() {
44 | return y;
45 | }
46 |
47 | public int getDistance()
48 | {
49 | return this.dist;
50 | }
51 |
52 | public void setDistance(int dist)
53 | {
54 | this.dist = dist;
55 | }
56 |
57 | public void setY(int y) {
58 | this.y = y;
59 | }
60 |
61 | public int getStatus() {
62 | return status;
63 | }
64 |
65 | public void setStatus(int status) {
66 | this.status = status;
67 | }
68 |
69 | public int getLabel() {
70 | return label;
71 | }
72 |
73 | public void setLabel(int label) {
74 | this.label = label;
75 | }
76 |
77 | public void addNeighour(PixelPoint p) {
78 | if (this.neighbours == null) {
79 | this.neighbours = new ArrayList();
80 | }
81 | this.neighbours.add(p);
82 | }
83 |
84 | public List getNeighbours() {
85 | return this.neighbours;
86 | }
87 |
88 | public int compareTo(PixelPoint object) {
89 |
90 | if (object.getValue() < getValue()) {
91 | return 1;
92 | }
93 | if (object.getValue() > getValue()) {
94 | return -1;
95 | }
96 | return 0;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/SquareTraceAlgorithm.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/SquareTraceAlgorithm.java
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/ThinPixel.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.ten;
2 |
3 | public class ThinPixel {
4 |
5 | public int getRow() {
6 | return row;
7 | }
8 |
9 | public void setRow(int row) {
10 | this.row = row;
11 | }
12 |
13 | public int getCol() {
14 | return col;
15 | }
16 |
17 | public void setCol(int col) {
18 | this.col = col;
19 | }
20 |
21 | public int getNumOfBlack() {
22 | return numOfBlack;
23 | }
24 |
25 | public void setNumOfBlack(int numOfBlack) {
26 | this.numOfBlack = numOfBlack;
27 | }
28 |
29 | public int getValue() {
30 | return value;
31 | }
32 |
33 | public void setValue(int value) {
34 | this.value = value;
35 | }
36 |
37 | public int getP2() {
38 | return P2;
39 | }
40 |
41 | public void setP2(int p2) {
42 | P2 = p2;
43 | }
44 |
45 | public int getP4() {
46 | return P4;
47 | }
48 |
49 | public void setP4(int p4) {
50 | P4 = p4;
51 | }
52 |
53 | public int getP6() {
54 | return P6;
55 | }
56 |
57 | public void setP6(int p6) {
58 | P6 = p6;
59 | }
60 |
61 | public int getP8() {
62 | return P8;
63 | }
64 |
65 | public void setP8(int p8) {
66 | P8 = p8;
67 | }
68 |
69 | private int row;
70 | private int col;
71 | private int numOfBlack;
72 | private int numOfConnectivity;
73 | public int getNumOfConnectivity() {
74 | return numOfConnectivity;
75 | }
76 |
77 | public void setNumOfConnectivity(int numOfConnectivity) {
78 | this.numOfConnectivity = numOfConnectivity;
79 | }
80 |
81 | private int value;
82 | private int P2;
83 | private int P4;
84 | private int P6;
85 | private int P8;
86 |
87 | public ThinPixel(int row, int col, int value) {
88 | this.row = row;
89 | this.col = col;
90 | this.value = value;
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/area-angle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/area-angle.png
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/binaryobject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/binaryobject.png
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/brain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/brain.png
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/connectedcomponents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/connectedcomponents.png
--------------------------------------------------------------------------------
/src/com/book/chapter/ten/tools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/ten/tools.png
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/CoOccurrenceMatrixFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/thirteen/CoOccurrenceMatrixFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/ColorFeatureExtractor.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/thirteen/ColorFeatureExtractor.java
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/GaussianDerivativeFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/thirteen/GaussianDerivativeFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/GaussianFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.thirteen;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class GaussianFilter extends AbstractBufferedImageOp {
8 | private float a;
9 | private float[] gaussianKeneral = null;
10 |
11 | public GaussianFilter() {
12 | a = 0.4f;
13 | generateGaussianKeneral();
14 | }
15 |
16 | public void setCofficience(float a) {
17 | this.a = a;
18 | }
19 |
20 | public float[][] getHVGaussianKeneral() {
21 | float[][] hvKeneralData = new float[5][5];
22 | float sum = 0;
23 | for(int i=0; i<5; i++)
24 | {
25 | for(int j=0; j<5; j++)
26 | {
27 | hvKeneralData[i][j] = gaussianKeneral[i] * gaussianKeneral[j];
28 | sum += hvKeneralData[i][j] ;
29 | }
30 | }
31 | System.out.println("Sum of Gaussian Keneral Data = " + sum);
32 | return hvKeneralData;
33 | }
34 |
35 | @Override
36 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
37 | int width = src.getWidth();
38 | int height = src.getHeight();
39 |
40 | if ( dest == null )
41 | dest = createCompatibleDestImage( src, null );
42 |
43 | int[] inPixels = new int[width*height];
44 | int[] outPixels = new int[width*height];
45 | getRGB( src, 0, 0, width, height, inPixels);
46 | blur( inPixels, outPixels, width, height); // H Gaussian
47 | blur( outPixels, inPixels, height, width); // V Gaussain
48 | setRGB(dest, 0, 0, width, height, inPixels );
49 | return dest;
50 | }
51 |
52 | private void blur(int[] inPixels, int[] outPixels, int width, int height)
53 | {
54 | int subCol = 0;
55 | int index = 0, index2 = 0;
56 | float redSum=0, greenSum=0, blueSum=0;
57 | for(int row=0; row= width) {
67 | subCol = 0;
68 | }
69 | index2 = row * width + subCol;
70 | ta = (inPixels[index2] >> 24) & 0xff;
71 | tr = (inPixels[index2] >> 16) & 0xff;
72 | tg = (inPixels[index2] >> 8) & 0xff;
73 | tb = inPixels[index2] & 0xff;
74 | redSum += (tr * gaussianKeneral[m + 2]);
75 | greenSum += (tg * gaussianKeneral[m + 2]);
76 | blueSum += (tb * gaussianKeneral[m + 2]);
77 | }
78 | outPixels[index] = (ta << 24) | (clamp(redSum) << 16) | (clamp(greenSum) << 8) | clamp(blueSum);
79 | index += height;
80 | }
81 | }
82 | }
83 |
84 | public static int clamp(float a) {
85 | return (int)(a < 0 ? 0 : ((a > 255) ? 255 : a));
86 | }
87 |
88 | private void generateGaussianKeneral() {
89 | gaussianKeneral = new float[]{0.25f-a/2.0f, 0.25f, a, 0.25f, 0.25f-a/2.0f};
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/GrayFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/thirteen/GrayFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/HarrisCornerDetector.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/thirteen/HarrisCornerDetector.java
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/HarrisMatrix.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.thirteen;
2 |
3 | public class HarrisMatrix {
4 | private double Ix;
5 | private double Iy;
6 | private double IxIy;
7 | private double r;
8 | private double max;
9 |
10 | public double getMax() {
11 | return max;
12 | }
13 |
14 | public void setMax(double max) {
15 | this.max = max;
16 | }
17 |
18 | public HarrisMatrix()
19 | {
20 | max = 0; // always
21 | }
22 |
23 | public double getXGradient() {
24 | return Ix;
25 | }
26 | public void setXGradient(double ix) {
27 | Ix = ix;
28 | }
29 | public double getYGradient() {
30 | return Iy;
31 | }
32 | public void setYGradient(double iy) {
33 | Iy = iy;
34 | }
35 |
36 | public double getIxIy() {
37 | return IxIy;
38 | }
39 |
40 | public void setIxIy(double ixIy) {
41 | IxIy = ixIy;
42 | }
43 |
44 | public double getR() {
45 | return r;
46 | }
47 |
48 | public void setR(double r) {
49 | this.r = r;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/HoughFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.thirteen;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | public class HoughFilter extends AbstractBufferedImageOp {
8 | public static final int LINE_TYPE = 1;
9 | public static final int CIRCLE_TYPE = 2;
10 | private int type;
11 |
12 | public HoughFilter(int type)
13 | {
14 | this.type = type;
15 | }
16 |
17 | public void setType(int type){
18 | this.type = type;
19 | }
20 |
21 | public int getType()
22 | {
23 | return this.type;
24 | }
25 |
26 | @Override
27 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
28 | int width = src.getWidth();
29 | int height = src.getHeight();
30 |
31 | if ( dest == null )
32 | dest = createCompatibleDestImage( src, null );
33 |
34 | int[] inPixels = new int[width*height];
35 | int[] outPixels = new int[width*height];
36 | getRGB( src, 0, 0, width, height, inPixels );
37 |
38 | if(type == LINE_TYPE)
39 | {
40 | LineHough lh = new LineHough();
41 | lh.init(inPixels, width, height);
42 | outPixels = lh.process();
43 | }
44 | else if(type == CIRCLE_TYPE)
45 | {
46 | CircleHough ch = new CircleHough();
47 | ch.init(inPixels, width, height, 40);
48 | outPixels = ch.process();
49 | }
50 | else
51 | {
52 | throw new IllegalArgumentException("Warning: not supported type...");
53 | }
54 |
55 | setRGB( dest, 0, 0, width, height, outPixels );
56 | return dest;
57 | }
58 |
59 | public BufferedImage getHoughSpaceImage(BufferedImage src, BufferedImage dest)
60 | {
61 | int width = src.getWidth();
62 | int height = src.getHeight();
63 |
64 | if ( dest == null )
65 | dest = createCompatibleDestImage( src, null );
66 |
67 | int[] inPixels = new int[width*height];
68 | getRGB( src, 0, 0, width, height, inPixels );
69 |
70 | if(type == LINE_TYPE)
71 | {
72 | LineHough lh = new LineHough();
73 | lh.init(inPixels, width, height);
74 | lh.process();
75 | int rmax = (int)Math.sqrt(width*width + height*height);
76 | BufferedImage houghImage = new BufferedImage(180, rmax, BufferedImage.TYPE_INT_ARGB);
77 | setRGB( houghImage, 0, 0, 180, rmax, lh.getAcc() );
78 | return dest;
79 | }
80 | else if(type == CIRCLE_TYPE)
81 | {
82 | CircleHough ch = new CircleHough();
83 | ch.init(inPixels, width, height, 40);
84 | ch.process();
85 | setRGB( dest, 0, 0, width, height, ch.getAcc() );
86 | return dest;
87 | }
88 | else
89 | {
90 | throw new IllegalArgumentException("Warning: not supported type...");
91 | }
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/LineHough.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.thirteen;
2 |
3 | public class LineHough {
4 | private int[] input;
5 | private int[] output;
6 | private int width;
7 | private int height;
8 | private int[] acc;
9 | private int accSize = 6;
10 | private int[] results;
11 |
12 | public LineHough() {
13 | System.out.println("Hough Line Detection...");
14 | }
15 |
16 | public void init(int[] inputIn, int widthIn, int heightIn) {
17 | width = widthIn;
18 | height = heightIn;
19 | input = new int[width * height];
20 | output = new int[width * height];
21 | input = inputIn;
22 | for (int y = 0; y < height; y++) {
23 | for (int x = 0; x < width; x++) {
24 | output[y * width + x] = 0xff000000;
25 | }
26 | }
27 | }
28 |
29 | /**
30 | * tell it how many lines should display...
31 | * @param lines
32 | */
33 | public void setLines(int lines) {
34 | accSize = lines;
35 | }
36 | /**
37 | * 1. 初始化霍夫变换空间
38 | * 2. 将图像的2D空间转换到霍夫空间,每个像素坐标都要转换到霍夫极坐标的对应强度值
39 | * 3. 找出霍夫极坐标空间的最大强度值
40 | * 4. 根据最大强度值归一化,范围为0 ~ 255
41 | * 5. 根据输入前accSize值,画出前accSize个信号最强的直线
42 | * @return
43 | */
44 | public int[] process() {
45 | int rmax = (int) Math.sqrt(width * width + height * height);
46 | acc = new int[rmax * 180]; // 0 ~ 180闇嶅か鍧愭爣绌洪棿
47 | int r;
48 |
49 | for (int x = 0; x < width; x++) {
50 | for (int y = 0; y < height; y++) {
51 |
52 | if ((input[y * width + x] & 0xff) == 255) {
53 |
54 | for (int theta = 0; theta < 180; theta++) {
55 | r = (int) (x * Math.cos(((theta) * Math.PI) / 180) + y * Math.sin(((theta) * Math.PI) / 180)); // 鍍忕礌鐐筽(x, y)杞崲涓哄搴旂殑寮哄害鍊�
56 | if ((r > 0) && (r <= rmax))
57 | acc[r * 180 + theta] = acc[r * 180 + theta] + 1; // 寮哄害鍊煎鍔�
58 | }
59 | }
60 | }
61 | }
62 |
63 | // 鎵惧埌鏋佸潗鏍囩┖闂寸殑鏈�ぇ寮哄害鍊�
64 | int max = 0;
65 | for (r = 0; r < rmax; r++) {
66 | for (int theta = 0; theta < 180; theta++) {
67 |
68 | if (acc[r * 180 + theta] > max) {
69 | // swap the max value
70 | max = acc[r * 180 + theta];
71 | }
72 | }
73 | }
74 |
75 | // normalization all the values, 褰掍竴鍖栧鐞�
76 | int value;
77 | for (r = 0; r < rmax; r++) {
78 | for (int theta = 0; theta < 180; theta++) {
79 |
80 | value = (int) (((double) acc[r * 180 + theta] / (double) max) * 255.0);
81 | acc[r * 180 + theta] = 0xff000000 | (value << 16 | value << 8 | value);
82 | }
83 | }
84 |
85 | // 缁樺埗鎵惧埌n涓洿绾�
86 | findMaxima();
87 |
88 | System.out.println("done");
89 | return output;
90 | }
91 |
92 | private int[] findMaxima() {
93 |
94 | // 鏋佸潗鏍囦腑鏈�ぇ鐨勫崐寰勫�
95 | int rmax = (int) Math.sqrt(width * width + height * height);
96 | results = new int[accSize * 3];
97 | int[] output = new int[width * height];
98 | // 鏍规嵁杈撳叆鍙傛暟,鎵惧埌鍓峚ccSize涓瀬鍧愭爣绌洪棿涓己搴︽渶澶х殑鐩寸嚎R鍊�
99 | for (int r = 0; r < rmax; r++) {
100 | for (int theta = 0; theta < 180; theta++) {
101 | int value = (acc[r * 180 + theta] & 0xff);
102 |
103 | // if its higher than lowest value add it and then sort
104 | if (value > results[(accSize - 1) * 3]) {
105 |
106 | // add to bottom of array
107 | results[(accSize - 1) * 3] = value;
108 | results[(accSize - 1) * 3 + 1] = r;
109 | results[(accSize - 1) * 3 + 2] = theta;
110 |
111 | // shift up until its in right place
112 | int i = (accSize - 2) * 3;
113 | while ((i >= 0) && (results[i + 3] > results[i])) {
114 | for (int j = 0; j < 3; j++) {
115 | int temp = results[i + j];
116 | results[i + j] = results[i + 3 + j];
117 | results[i + 3 + j] = temp;
118 | }
119 | i = i - 3;
120 | if (i < 0)
121 | break;
122 | }
123 | }
124 | }
125 | }
126 |
127 |
128 | // 鏍规嵁鏋佸潗鏍囪褰曠殑R鍊�鍖归厤瀵瑰簲鐨勫儚绱犵偣,缁樺埗鍑烘娴嬪埌寰楃洿绾�
129 | System.out.println("Total " + accSize + " matches:");
130 | for (int i = accSize - 1; i >= 0; i--) {
131 | drawPolarLine(results[i * 3], results[i * 3 + 1],results[i * 3 + 2]);
132 | }
133 | return output;
134 | }
135 |
136 | // 缁樺埗鐩寸嚎鏂规硶
137 | private void drawPolarLine(int value, int r, int theta) {
138 | for (int x = 0; x < width; x++) {
139 | for (int y = 0; y < height; y++) {
140 | int temp = (int) (x * Math.cos(((theta) * Math.PI) / 180) + y * Math.sin(((theta) * Math.PI) / 180));
141 | if ((temp - r) == 0) // 鍖归厤瀵瑰簲鍍忕礌鐐�缁樺埗鐩寸嚎
142 | output[y * width + x] = 0xffff0000; // 缁撴灉鐩寸嚎涓虹孩鑹�
143 | }
144 | }
145 | }
146 |
147 | public int[] getAcc() {
148 | return acc;
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/PyramidDemoUI.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/thirteen/PyramidDemoUI.java
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/sift/Feature.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.thirteen.sift;
2 |
3 |
4 | import java.io.Serializable;
5 |
6 | /**
7 | * SIFT feature container
8 | */
9 | public class Feature implements Comparable< Feature >, Serializable
10 | {
11 | public float scale;
12 | public float orientation;
13 | public float[] location;
14 | public float[] descriptor;
15 |
16 | /** Dummy constructor for Serialization to work properly. */
17 | public Feature() {}
18 |
19 | public Feature( float s, float o, float[] l, float[] d )
20 | {
21 | scale = s;
22 | orientation = o;
23 | location = l;
24 | descriptor = d;
25 | }
26 |
27 | /**
28 | * comparator for making Features sortable
29 | * please note, that the comparator returns -1 for
30 | * this.scale > o.scale, to sort the features in a descending order
31 | */
32 | public int compareTo( Feature f )
33 | {
34 | return scale < f.scale ? 1 : scale == f.scale ? 0 : -1;
35 | }
36 |
37 | public float descriptorDistance( Feature f )
38 | {
39 | float d = 0;
40 | for ( int i = 0; i < descriptor.length; ++i )
41 | {
42 | float a = descriptor[ i ] - f.descriptor[ i ];
43 | d += a * a;
44 | }
45 | return ( float )Math.sqrt( d );
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/sift/Float2DArray.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.thirteen.sift;
2 |
3 | import java.util.Arrays;
4 |
5 | public class Float2DArray {
6 | protected float[] data;
7 | protected int width;
8 | protected int height;
9 |
10 | public Float2DArray(int width, int height) {
11 | this.width = width;
12 | this.height = height;
13 | data = new float[width * height];
14 | }
15 |
16 | public float getValue(int x, int y) {
17 | int index = y * width + x;
18 | return data[index];
19 | }
20 |
21 | public float getZero(int x, int y)
22 | {
23 | if (x >= width)
24 | return 0;
25 |
26 | if (y >= height)
27 | return 0;
28 |
29 | if (x < 0)
30 | return 0;
31 |
32 | if (y < 0)
33 | return 0;
34 |
35 | return getValue(x,y);
36 | }
37 |
38 | public void setValue(int x, int y, float value) {
39 | int index = y * width + x;
40 | data[index] = value;
41 | }
42 |
43 | public int getWidth() {
44 | return width;
45 | }
46 |
47 | public int getHeight() {
48 | return height;
49 | }
50 |
51 | public void reset()
52 | {
53 | Arrays.fill(data, 0f);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/sift/SIFTFeatureDetector.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/thirteen/sift/SIFTFeatureDetector.java
--------------------------------------------------------------------------------
/src/com/book/chapter/thirteen/sift/ScaleOctave.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.thirteen.sift;
2 |
3 |
4 |
5 | public class ScaleOctave {
6 | public final static int min_size = 64;
7 | public final static int max_size = 1024;
8 | public int STEPS = 1;
9 | public int width = 0;
10 | public int height = 0;
11 |
12 | private float K = 2.0f;
13 | private float K_MIN1_INV = 1.0f / ( K - 1.0f );
14 | protected float[] sigma;
15 | private float[] sigmaDiff;
16 | private float[][] kenDiff;
17 | private Float2DArray[] images;
18 | private Float2DArray[] DoG;
19 |
20 | public ScaleOctave(Float2DArray src, float[] sigma, float[] sigmaDiff, float[][] kenDiff)
21 | {
22 | width = src.width;
23 | height = src.height;
24 | if(width == 0 || height == 0)
25 | {
26 | throw new java.lang.IllegalArgumentException("width or height of image is not correct");
27 | }
28 | if((width max_size) || (height max_size))
29 | {
30 | throw new java.lang.IllegalArgumentException("width or height of image is not correct");
31 | }
32 | images = new Float2DArray[1];
33 | STEPS = sigma.length - 3;
34 | images[0] = src;
35 | K = ( float )Math.pow( 2.0, 1.0 / ( float )STEPS );
36 | K_MIN1_INV = 1.0f / ( K - 1.0f );
37 | width = src.width;
38 | height = src.height;
39 | this.sigma = sigma;
40 | this.sigmaDiff = sigmaDiff;
41 | this.kenDiff = kenDiff;
42 | }
43 |
44 | public void buildStub()
45 | {
46 | Float2DArray img = images[ 0 ];
47 | images = new Float2DArray[ 2 ];
48 | images[ 0 ] = img;
49 | images[ 1 ] = GaussianUtil.convolveSeparable( images[ 0 ], kenDiff[STEPS], kenDiff[STEPS] );
50 | }
51 |
52 | public Float2DArray getLevel(int index)
53 | {
54 | return images[index];
55 | }
56 |
57 | public Float2DArray[] getDoGs()
58 | {
59 | return DoG;
60 | }
61 |
62 |
63 |
64 | public void build()
65 | {
66 | // build image pyramid
67 | Float2DArray img = images[0];
68 | Float2DArray img2 = images[1];
69 | // build S + 3 images, must have according to paper 2004
70 | images = new Float2DArray[STEPS + 3];
71 | images[0] = img;
72 | images[STEPS] = img2;
73 | for ( int i = 1; i < kenDiff.length; ++i )
74 | {
75 | if (i == STEPS ) continue;
76 | images[ i ] = GaussianUtil.convolveSeparable( images[0], kenDiff[i], kenDiff[i] );
77 | }
78 | // build DOG images
79 | DoG = new Float2DArray[ STEPS + 2 ];
80 | for ( int i = 0; i < DoG.length; ++i )
81 | {
82 | DoG[ i ] = new Float2DArray(images[i].width, images[i].height );
83 | int j = i + 1;
84 | for ( int k = 0; k < images[ i ].data.length; ++k )
85 | {
86 | DoG[ i ].data[ k ] = ( images[ j ].data[ k ] - images[ i ].data[ k ] ) * K_MIN1_INV;
87 | }
88 | }
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/com/book/chapter/three/ImagePanel.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/three/ImagePanel.java
--------------------------------------------------------------------------------
/src/com/book/chapter/three/MainUI.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/three/MainUI.java
--------------------------------------------------------------------------------
/src/com/book/chapter/twelves/ClusterCenter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.twelves;
2 |
3 | public class ClusterCenter {
4 |
5 | public ClusterCenter(int row, int col)
6 | {
7 | this.row = row;
8 | this.col = col;
9 | this.index = -1;
10 | this.numOfPixels = 0;
11 | }
12 | public int getRow() {
13 | return row;
14 | }
15 | public void setRow(int row) {
16 | this.row = row;
17 | }
18 | public int getCol() {
19 | return col;
20 | }
21 | public void setCol(int col) {
22 | this.col = col;
23 | }
24 | public int[] getRGB() {
25 | return rgb;
26 | }
27 | public void setRGB(int[] cValue) {
28 | this.rgb = cValue;
29 | }
30 | public int getIndex() {
31 | return index;
32 | }
33 | public void setIndex(int index) {
34 | this.index = index;
35 | }
36 | public int getNumOfPixels() {
37 | return numOfPixels;
38 | }
39 | public void setNumOfPixels(int numOfPixels) {
40 | this.numOfPixels = numOfPixels;
41 | }
42 |
43 | public void addNumOfPixel()
44 | {
45 | numOfPixels++;
46 | }
47 |
48 | private int row;
49 | private int col;
50 | private int[] rgb;
51 | private int index;
52 | private int numOfPixels;
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/com/book/chapter/twelves/FCClusterCenter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.twelves;
2 |
3 | public class FCClusterCenter {
4 |
5 | public FCClusterCenter(int row, int col)
6 | {
7 | this.row = row;
8 | this.col = col;
9 | }
10 |
11 | public double getRow() {
12 | return row;
13 | }
14 | public void setRow(double row) {
15 | this.row = row;
16 | }
17 | public double getCol() {
18 | return col;
19 | }
20 | public void setCol(double col) {
21 | this.col = col;
22 | }
23 | public int getPvalue() {
24 | return pvalue;
25 | }
26 | public void setPvalue(int pvalue) {
27 | this.pvalue = pvalue;
28 | }
29 | public double getRedSum() {
30 | return redSum;
31 | }
32 | public void setRedSum(double redSum) {
33 | this.redSum = redSum;
34 | }
35 | public double getGreenSum() {
36 | return greenSum;
37 | }
38 | public void setGreenSum(double greenSum) {
39 | this.greenSum = greenSum;
40 | }
41 | public double getBlueSum() {
42 | return blueSum;
43 | }
44 | public void setBlueSum(double blueSum) {
45 | this.blueSum = blueSum;
46 | }
47 | public double getMemberShipSum() {
48 | return memberShipSum;
49 | }
50 | public void setMemberShipSum(double memberShipSum) {
51 | this.memberShipSum = memberShipSum;
52 | }
53 | public int getOriginalPvalue() {
54 | return originalPvalue;
55 | }
56 | public void setOriginalPvalue(int originalPvalue) {
57 | this.originalPvalue = originalPvalue;
58 | }
59 | private double row;
60 | private double col;
61 | private int pvalue;
62 | private double redSum;
63 | private double greenSum;
64 | private double blueSum;
65 | private double memberShipSum;
66 | private int originalPvalue;
67 | }
68 |
--------------------------------------------------------------------------------
/src/com/book/chapter/twelves/MeanPoint.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.twelves;
2 |
3 | public class MeanPoint {
4 | public MeanPoint(int row, int col, float[] rgb) {
5 | this.row = row;
6 | this.col = col;
7 | this.rgb = rgb;
8 | }
9 |
10 | public int getRow() {
11 | return row;
12 | }
13 |
14 | public void setRow(int row) {
15 | this.row = row;
16 | }
17 |
18 | public int getCol() {
19 | return col;
20 | }
21 |
22 | public void setCol(int col) {
23 | this.col = col;
24 | }
25 |
26 | public float[] getRgb() {
27 | return rgb;
28 | }
29 |
30 | public void setRgb(float[] rgb) {
31 | this.rgb = rgb;
32 | }
33 |
34 | private int row;
35 | private int col;
36 | private float[] rgb;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/book/chapter/twelves/MeanShiftAlgo.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/twelves/MeanShiftAlgo.java
--------------------------------------------------------------------------------
/src/com/book/chapter/twelves/OtsuBinaryFilter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gloomyfish/mybook-java-imageprocess/58e0ce079e6938e7c018d59095f0ff0e97d6e8ef/src/com/book/chapter/twelves/OtsuBinaryFilter.java
--------------------------------------------------------------------------------
/src/com/book/chapter/twelves/PixelPoint.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.twelves;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 |
7 | public class PixelPoint implements Comparable {
8 | public final static int UNMARKED = -1;
9 | public final static int VISITED = 1;
10 | public final static int MARKED = 2;
11 | public PixelPoint(int row, int col, int pixel) {
12 | this.status = UNMARKED;
13 |
14 | this.value = pixel;
15 | this.col = col;
16 | this.row = row;
17 | this.dist = 0;
18 | }
19 |
20 | public PixelPoint(int row, int col)
21 | {
22 | this.row = row;
23 | this.col = col;
24 | }
25 | public int getRow() {
26 | return row;
27 | }
28 |
29 | public void setRow(int row) {
30 | this.row = row;
31 | }
32 |
33 | public int getCol() {
34 | return col;
35 | }
36 |
37 | public void setCol(int col) {
38 | this.col = col;
39 | }
40 |
41 | public float[] getRGB() {
42 | return rgb;
43 | }
44 |
45 | public void setRGB(float[] value) {
46 | this.rgb = value;
47 | }
48 |
49 | public int getLable() {
50 | return lable;
51 | }
52 |
53 | public void setLable(int lable) {
54 | this.lable = lable;
55 | }
56 |
57 | public double possible;
58 |
59 | public double getPossible() {
60 | return possible;
61 | }
62 | public void setPossible(double possible) {
63 | this.possible = possible;
64 | }
65 |
66 | private int row;
67 | private int col;
68 | private float[] rgb;
69 | private int lable;
70 | private int value;
71 | private int status;
72 | public int getValue() {
73 | return value;
74 | }
75 |
76 | public void setValue(int value) {
77 | this.value = value;
78 | }
79 |
80 | public int getStatus() {
81 | return status;
82 | }
83 |
84 | public void setStatus(int status) {
85 | this.status = status;
86 | }
87 |
88 | public int getDist() {
89 | return dist;
90 | }
91 |
92 | public void setDist(int dist) {
93 | this.dist = dist;
94 | }
95 |
96 | public List getNeighbours() {
97 | return neighbours;
98 | }
99 |
100 | public void setNeighbours(List neighbours) {
101 | this.neighbours = neighbours;
102 | }
103 |
104 | private int dist;
105 | private List neighbours = null;
106 |
107 | @Override
108 | public int compareTo(PixelPoint object) {
109 | if (object.getValue() < getValue()) {
110 | return 1;
111 | }
112 | if (object.getValue() > getValue()) {
113 | return -1;
114 | }
115 | return 0;
116 | }
117 |
118 | public void addNeighour(PixelPoint pixelPoint) {
119 | if(this.neighbours == null)
120 | {
121 | this.neighbours = new ArrayList();
122 | }
123 | this.neighbours.add(pixelPoint);
124 |
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/src/com/book/chapter/twelves/SobelEdgeFilter.java:
--------------------------------------------------------------------------------
1 | package com.book.chapter.twelves;
2 |
3 | import java.awt.image.BufferedImage;
4 |
5 | import com.book.chapter.four.AbstractBufferedImageOp;
6 |
7 | /***
8 | * based on gray level image
9 | *
10 | */
11 | public class SobelEdgeFilter extends AbstractBufferedImageOp {
12 | public static final int[][] X_SOBEL = new int[][]{{-1,-2,-1},{0,0,0},{1,2,1}};
13 | public static final int[][] Y_SOBEL = new int[][]{{-1, 0, 1},{-2,0,2},{-1,0,1}};
14 |
15 | public SobelEdgeFilter()
16 | {
17 | System.out.println("Sobel Edge Detection!");
18 | }
19 |
20 | @Override
21 | public BufferedImage filter(BufferedImage src, BufferedImage dest) {
22 | int width = src.getWidth();
23 | int height = src.getHeight();
24 | if ( dest == null )
25 | dest = createCompatibleDestImage( src, null );
26 | int[] inPixels = new int[width*height];
27 | int[] outPixels = new int[width*height];
28 | int[] x_gradient = new int[width*height];
29 | int[] y_gradient = new int[width*height];
30 | getRGB(src, 0, 0, width, height, inPixels );
31 | int index = 0;
32 | for(int row=0; row= height)
43 | {
44 | nrow = 0;
45 | }
46 | if(ncol < 0 || ncol >= width)
47 | {
48 | ncol = 0;
49 | }
50 | index = nrow * width + ncol;
51 | tr = (inPixels[index] >> 16) & 0xff;
52 | tg = (inPixels[index] >> 8) & 0xff;
53 | tb = inPixels[index] & 0xff;
54 | xg += X_SOBEL[sr+1][sc+1] * tr;
55 | yg += Y_SOBEL[sr+1][sc+1] * tr;
56 | }
57 | }
58 | index = row * width + col;
59 | x_gradient[index] = xg;
60 | y_gradient[index] = yg;
61 | outPixels[index] = (int)Math.sqrt(x_gradient[index] * x_gradient[index]+y_gradient[index]*y_gradient[index]);
62 | }
63 | }
64 |
65 | // normalization the MAX
66 | int max = 0;
67 | for(int row=0; row