C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 4th, 2013, 08:57 AM
defunktlemon defunktlemon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 16 defunktlemon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 8 sec
Reputation Power: 0
Loop and add pixel values c#

I have image_1 in PictureBox1. I want to scan through a rectangular section in the middle of this image, say about 300 to 500 on the x-axis and 300 to 450 on the y-axis. When I scan through this section I want to add up the values of all the pixels and get an average value for them.

I then have image_2 in PictureBox2, the test image. This is a copy of the first image but the PictureBox2 has a scroll bar on it. If I then scan through the second image at the same locations as I did with the first image, sum every pixel value within that rectangle and get an average of them the values should be exactly the same as the value I got with image_1.

Now, I will move image_2 with the scroll bar on PictureBox2 slightly up in the vertical, y-axis, and redo the scan in the same fixed locations as previously, add up the pixel values and get their average. These values should be different because I am scanning a different section of the image.
I then repeat this process some more with varying degrees of difference in the y-axis on image_2 to get value readings.

This is to prove a concept only. That scanning the images at a fixed rectangular location, summing and averaging values is enough to eventually narrow down the values so that the beginning of an object can be located.

Whether this is thought to be possible or not I would like to attempt it.
Please advise the simplest method. It is not necessary at this stage to attempt the fastest or most efficient method, purely the simplest is best at present

Is it something I can simply do like this?
Collapse | Copy Code

Code:
namespace imageAlign
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap myImage1 = (Bitmap)pictureBox1.Image;
            OpenFileDialog ofd1 = new OpenFileDialog();
            if (ofd1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                pictureBox1.Image = Image.FromFile(ofd1.FileName);
               
                        // get pixel value and store it in array, sum and average it so it can Be compared to image2
                int sum = 0;
                         for (int i = 0; i > 300 && i < 500; i++)
                         {
                             for (int j = 0; j > 300 && j < 450; i++)
                            {
                                int[] img1 = new int[i];
                                sum += img1[i];
                                MessageBox.Show(sum);
                                 //Color pixel = img1.GetPixel(i,j);
                                 //sum and average pixel values in array
                    }
                }
            }
 
        }



Thank you all.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Loop and add pixel values c#

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap