Ask Your Question

william's profile - activity

2016-11-09 13:18:44 -0600 received badge  Taxonomist
2013-10-24 03:18:49 -0600 received badge  Student (source)
2013-08-03 22:59:29 -0600 commented answer Block Overlapped Histogram Equalization

However the code i wrote has some errors, the Output Image only compute local histogram equalization at the second column (pixels below 1). The border pixels has white intensity and the other pixels are all black as shown above in Output Image. Why my code cannot run "histogram[<uchar>(y+k,x-r-1)]--;" and "histogram[<uchar>(y+k,x+r)]++;"? Please advise. Thank you.

2013-08-03 22:13:37 -0600 commented answer Block Overlapped Histogram Equalization

I had just insert a picture above for reference. Initially I will compute the local histogram equalization of the first 3 x 3 kernel (center and indicated by 1 in the picture). Then I will move from left to right to the second pixel and compute the second local histogram equalization (center and indicated by 2 in the picture). To do a fast algorithm, I just want to delete the first column and add the fourth column to the previous histogram as indicated by ( - ) and ( + ) in the above picture. At the 8 th column, after finish computing local histogram equalization on the first row, I want to move to the second row and 8th column, then sliding from right to left.

2013-08-03 11:52:56 -0600 asked a question Block Overlapped Histogram Equalization

I want to do a block overlapped histogram equalization with a 3x3 kernel with fast algorithm. For example, given a 9x9 image (with rows from 0 to 8 ; and columns from 0 to 8). The location for each pixel will be given as: (rows, columns) i.e (height, width). First the pixel at location (1,1) will be computed using a 3x3 kernel to obtain the first kernel histogram. Then move to the second pixel at location (1,2), here I would like to delete pixel at location (0,0), (1,0), (2,0) and add pixel at location (0,3), (1,3), (2,3) to the previous kernel histogram while maintaining pixels at locations (0,1), (1,1) (2,1) and (0,2) (1,2) (2,2). The window will slides from left to right until the second last column at (1,7). In the OutputImage, I can only compute the kernel histogram with column=1 (i.e x==cr_w/2) while other kernel histograms cannot be computed. Is there something wrong at “histogram[<uchar>(y+k,x-r-1)]--;” and “histogram[<uchar>(y+k,x+r)]++;” in the code I wrote below? Please advise.

After finish sliding the first row at (1,7), I wand to continue with the second row at location (2,7) by deleting pixels at first row and adding pixels at fourth row. Then I would like to slide from right to left. How do I need to modify my code so that it can run till the last pixel at (7,7)?

image description

image description


    int nl = image.rows; // image height
int nc = image.cols; // image width
unsigned int TransferFunction[256];
cv::Mat OutputImage(nc, nl, CV_8U,cv::Scalar(255));

int cr_w;
int cr_h;
cout<<"\nPlease enter contextual region width = ";
cin>> cr_w;
cout<<"\nPlease enter contextual region height = ";
cin>> cr_h;

   for (int y=cr_h/2; y<nl-cr_h/2; y++)
    for (int x=cr_w/2; x<nc-cr_w/2; x++) 
        // update histogram;
        for(int i=0; i<256; i++)
            histogram[i] = 0;

        int top = y-cr_h/2;
        int bottom = y+cr_h/2;

        int left = x-cr_w/2;
        int right = x+cr_w/2;

        int r = cr_h/2; //window radius

                if (x == cr_w/2)
        for (int j=top; j<=bottom; j++)
            for (int i=left; i<=right; i++)

                for(int k=-cr_h/2; k<=ch_w/2; k++)

  HE(histogram, 0, 255, TransferFunction);    //histogram equalization function<uchar>(y,x) = TransferFunction[int(<uchar>(y,x))];

2013-06-01 11:10:48 -0600 asked a question Error left operand must be l-value

Hi, please help.

I got an error while building my program: "error C2106: '=' : left operand must be l-value". Actually i want to assign first pixel of Output_image with first pixel of 3x3 Gaussian mask, then second pixel of Output_image with second pixel of 5x5 Gausssian mask and so on. I figure that the problem come from the line [int(<uchar>(x,y)) = int(<uchar>(x,y))] for the program shown below:


for(int x=0; x<image_height; x++)
        for(int y=0; y<image_width; y++)
              int(<uchar>(x,y)) = int(<uchar>(x,y));
            else if (y%2==1)
              int(<uchar>(x,y)) = int(<uchar>(x,y));

Is it correct for me to assign [int(<uchar>(x,y)) = int(<uchar>(x,y))]? Please advise me on how to solve the above error.

Thamk you very much.

2013-05-30 10:18:18 -0600 received badge  Editor (source)
2013-05-26 09:47:19 -0600 asked a question Output image which combine pixels from different smoothing filter mask

Hi, please help.

How do I write code using OpenCV for the problem below:

Given an input image f(x), I want to produce an output image g(x) with: 1) first pixel using the original pixel value 2) second pixel with 3x3 smoothing filter mask value and 3) third pixel with 5x5 smoothing filter mask value

The remaining pixels will repeat the above 3 steps until the last pixels.

Currently I am able to produce the smooth image of 3x3 and 5x5 mask filter. However i cant figure out how to combine this smooth pixels into one output image g(x) like the condition given above.

Please help and advise.

Thank you very much.

Below is my code for the above question. The compilation error is: (error C2106: '=' : left operand must be l-value). This error flag when assigning pixel for the output image with first pixel using original image pixel, second pixel using 3x3 filter mask pixel value, third pixel using 5x5 filter mask pixel value.

include <iostream>

include <fstream>

include <math.h>

include "cv.h"

include "highgui.h"

include <create _own="" histogram.h="">

int image_height; int image_width; cv::Mat image; Histogram1D h; using namespace std;

int main() {

// Read input image
image= cv::imread("fl.pgm",0);
std::cout << "size: " << image.size().height << " , " << image.size().width << std::endl;
return 0;
cv::Mat imageClone3= image.clone();
cv::Mat imageClone5= image.clone();
cv::Mat result_3(image_height, image_width, CV_8U,cv::Scalar(255));
cv::Mat result_5(image_height, image_width, CV_8U,cv::Scalar(255));
cv::Mat OutputImage(image_height, image_width, CV_8U,cv::Scalar(255));

image_height = image.rows;
image_width = image.cols;

    //Display the image

cv::Mat image3, image5; cv::GaussianBlur(imageClone3,result_3,cv::Size(3,3),0,0); //3x3 filter mask cv::GaussianBlur(imageClone5,result_5,cv::Size(5,5),0,0); //5x5 filter mask

cv::namedWindow("Image Result_3"); cv::imshow("Image Result_3",result_3); cv::imwrite("3x3.bmp",result_3);

cv::namedWindow("Image Result_5"); cv::imshow("Image Result_5",result_5); cv::imwrite("5x5.bmp",result_5);

for (int i=0; i<image_height; i++)="" for="" (int="" j="0;" j<image_width;="" j++)="" {="" if(j%3="=0)" int(<uchar="">(i,j)) = int(<uchar>(i,j)); //first pixel of output image using the original input pixel value

            else if(j%3==1)
    int(<uchar>(i,j)) = int(<uchar>(i,j)); // second pixel of output image using 3x3 filter mask 

    else if(j%3==2)
    int(<uchar>(i,j)) = int(<uchar>(i,j)); // third pixel of output image using 5x5 filter mask 


return 0;


Please help me to solve the above problem. Thank you.