#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0

    C# align bitmap image


    Hi. I would like to do some image processing in C# and need to align two images before applying a filter to them. I will attempt to do this by scanning the images at a fixed point in a small rectangular section, which I believe makes it necessary to use the Bitmap class. This section has a large amount of white pixels so I would like to take an average pixel value in this area to find the shift in the y-axis, as there is a large white horizontal bar going across the images. The x-axis will be the same in both images. I would like to setup a few test images with different shift values, from small to large, positive and negative, so I can search for the minimum value . This will require a scroll bar on the images to move them in small amounts. I am totally new to C#, and low level programmer. I have been trying to get the image in pictureBox1 with the following code.


    Code:
    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing.Imaging; 
    using System.Drawing; 
    using System.Linq; 
    using System.Text; 
    using System.Windows.Forms;
     
    namespace imageAlign
     
    { public partial class Form1 : Form
     
    {
        public Form1()
     
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap myImage = (Bitmap)pictureBox1.Image;
            OpenFileDialog ofd = new OpenFileDialog();
     
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) ;
            {
                pictureBox1.Image = Image.FromFile();
     
    
               // this.pictureBox1.Image = myImage;
            }
        }
    }
     
    }
    I have left the Image.FromFile(); with nothing passed as I wish to choose the images when I click the button on the form. Currently, I only have one button and picture box.

    Thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    16
    Rep Power
    0
    I have a solution that works

    Code:
            Bitmap myImage = (Bitmap)pictureBox1.Image;
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) ;
            {
                pictureBox1.Image = Image.FromFile(ofd.FileName);
            }
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0
    if you are all new to the C#. you had better take a look at the web. a lot of image precessing codes in C# . include c# bitmap image

IMN logo majestic logo threadwatch logo seochat tools logo