private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image = Bitmap.FromFile(openFileDialog1.FileName);
                org = (Bitmap)pictureBox1.Image.Clone();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image.Save(saveFileDialog1.FileName);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Bitmap temp = (Bitmap)org.Clone();
            ot.Convert2GrayScaleFast(temp);
            int otsuThreshold= ot.getOtsuThreshold((Bitmap)temp);
            ot.threshold(temp,otsuThreshold);
            textBox1.Text = otsuThreshold.ToString();
            pictureBox1.Image = temp;
            

             //public Blob()
        //{
            using (IplImage img = new IplImage(  [B][U]get the threshold image[/U][/B]  , LoadMode.Color))
            using (IplImage chB = new IplImage(img.Size, BitDepth.U8, 1))
            using (IplImage labelImg = new IplImage(img.Size, CvBlobLib.DepthLabel, 1))
            {

my problem is : i have an image in the picture box. when i push the button 2 i apply the function threshold and after that i want to apply function blob in threshold image without I step other button
the problem they is that I do not know that I will say to him get the picture that has become threshold and applied above in this other interelation. I thank for the answers.

Edited 7 Years Ago by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

basically I want to put in the second function the address of changed picture and this i want to do it by pressing one button.

basically I want to put in the second function the address of changed picture and this i want to do it by pressing one button.

You have a third button that requires that the user has already thresholded the image (button2), right? So this will "click" button 2 for you if the user has not done so already. Is that what you were talking about?

Or am I totally missing it and you want a button to fill in that function parameter? Seems to me you could keep the (filename? is that what the parameter is) in a string and check it to see if empty before the function is called and if not flash the button and remind the user.

Edited 7 Years Ago by jonsca: n/a

the third button is for saving the final image, it does not occupy us, i want to write the address of the changed image in the first using.sorry for the engish i am not good.

My apologies, it is not your fault.

Could you call org = (Bitmap)pictureBox1.Image.Clone(); in the button2_Click method also to get a copy of the bitmap to pass into your function? Use the picturebox as a go-between, just do some error checking to make sure something was still there.

if i've understood you correctly, you want to apply the blob method to the image after you have applied the threshold.
Try this:

private void button2_Click(object sender, EventArgs e)
        {
            Bitmap temp = (Bitmap)org.Clone();
            ot.Convert2GrayScaleFast(temp);
            int otsuThreshold= ot.getOtsuThreshold((Bitmap)temp);
            ot.threshold(temp,otsuThreshold);
            textBox1.Text = otsuThreshold.ToString();
            temp = Blob(temp);
            pictureBox1.Image = temp;
        }

        private Bitmap Blob(Bitmap input)
        {
            using (IplImage img = new IplImage(input, LoadMode.Color))
            using (IplImage chB = new IplImage(img.Size, BitDepth.U8, 1))
            using (IplImage labelImg = new IplImage(img.Size, CvBlobLib.DepthLabel, 1))
            {
                //do Blob
                //return Blobbed image
                return img;
            }
        }

Im not sure what Blob involves or what the return type would be, but that should give you a starting point.

i try it and the variable input was wrong
Error 2 Argument '1': cannot convert from 'System.Drawing.Bitmap' to 'string'

what did you try and where did it throw the error? I'm not entirely sure what the IplImage type is so it may be a problem there.

The code i gave you was a guideline to show you how to pass the image to the blob method without the user having to click the buttons. What happens isnide the blob method will need to be written by you as i have no clue what its supposed to do.

i try to do that you are said but the IplImage accepts only the address of the image, not the image, anyway i found a way i save the image in a path. [temp.save("c:\\mybitmap.bmp");] and then I accomplished to applied to the second function. Thanks a lot for your time and your answers.

This article has been dead for over six months. Start a new discussion instead.