Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You goal in this project is two-fold: Create a java program that will print out the following statistics about an image (gray-level image of one

You goal in this project is two-fold:

  1. Create a java program that will print out the following statistics about an image (gray-level image of one channel). A color image must be converted to gray level using the utility functions provided to you.
    1. Overall mean of the image
    2. Overall variance of the image
    3. The dynamic range of the image
  2. As an application of the mean, you will also create a function that will take an image, a top-left corner coordinate, a block size and a sub-block size and return an image that has the passed block blurred (by blurring the subblocks within it)
    1. For example, you would specify the block at I,J of a given block size (for example 32). You will then identify the block and break it into sub-blocks (for example of size 4). For each subblock, you will then compute the mean and replace all the pixels in the subblock by their mean.
    2. The subblocks will be blurred because you replaced every pixel with its mean.
    3. You can access the subblocks with a double loop that starts at I,J and increment by the subblock size

for(int i = I; i < I + BlockSize; i += subblockSize) {

for(int j=J; j < J + BlockSize; j += subblockSize) {

Identify subblock

Calculate mean

Replace each pixel by the mean with proper cast and clipping

}

}

I already know how to do the first part of the assignment that asks to calculate mean, variance, and dynamic range. What I need help with is the second part that asks to identify a sub-block and blur each pixel in the sub-block using the mean of the sub-block. I don't know how to access the pixels in the sub-blocks.

This is the function I'm using to blur the image, but it doesn't blur the image correctly.

public static BufferedImage blurImage(byte[][] imageArray, int I, int J, int blockSize, int subBlockSize) { byte[][] subBlock = new byte[subBlockSize][subBlockSize]; int subBlockMean = 0; for (int i = I; i < I + blockSize; i+= subBlockSize) { for (int j = J; j < J + blockSize; j += subBlockSize){ for (int k = 0; k < subBlockSize; k++) { for (int l = 0; l < subBlockSize; l++) { System.arraycopy(imageArray,i,subBlock,0,subBlockSize); subBlockMean = calculateMean(subBlock); imageArray[k + i][l + j] = (byte)ImageIo.clip(subBlockMean); } } } } BufferedImage blurredImage = ImageIo.setGrayByteImageArray2DToBufferedImage(imageArray); ImageIo.writeImage(blurredImage, "jpg", "blurredImage.jpg"); return blurredImage;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

4. What advice would you give to Carol Sullivan-Diaz?

Answered: 1 week ago