TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Christos Alexiou
NA
61
0
Elimination of horizontal lines in an image using C# ?
May 18 2010 1:05 AM
Hi,
First of all congratulation for this forum,it's really useful.
My point is:
I have made an application of image processing.
This application contains three picture boxes and three buttons,pictureBox1, pictureBox2,pictuerBox3.
The first button which name is "Load" loads the picture we choose in the first picture box (pictureBox1)
The second button which name is "Process" edits the loaded image and in the same time, image appears in the second picture Box(pictureBox2)
The third button which name is "Stage 2" edits the pixel (resize them) and loads the image from the second picture box to the third picture box (pictureBox3).
My problem is that in the last picture box my loaded image appears with horizontal lines...How can I eliminate the horizontal white lines from the third image in the last picture box (pictureBox3)????
The full code for all these above is:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SetPixel_4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Action of "Load" button
private void button1_Click(object sender, EventArgs e)
{ //Load an image
try
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(open.FileName);
}
}
catch (Exception)
{
throw new ApplicationException("Failed loading image");
}
}
// Pass the image to process to our method
private void SetMyPicture(Image pbImage)
{
// Make sure that the image isn't null first
if (pbImage != null)
{
Bitmap myBitmap = new Bitmap(pbImage);
for (int Xcount = 0; Xcount < myBitmap.Width; Xcount=Xcount+10)
{
for (int Ycount = 0; Ycount < myBitmap.Height; Ycount++)
{
if (Xcount % 10 == 0)
{
myBitmap.SetPixel(Xcount, Ycount, Color.White);
}
}
}
for (int Xcount = 0; Xcount < myBitmap.Width; Xcount++)
{
for (int Ycount = 0; Ycount < myBitmap.Height; Ycount = Ycount+10)
{
if (Ycount % 10 == 0)
{
myBitmap.SetPixel(Xcount, Ycount, Color.White);
}
}
}
pictureBox2.Image = myBitmap;
}
}
//Action of "Process" button
private void button2_Click_1(object sender, EventArgs e)
{
// calling my method and give it the first picturebox's Image.
SetMyPicture(pictureBox1.Image);
}
//Action for button "Stage 2"
private void button3_Click(object sender, EventArgs e)
{
Stage2(pictureBox2.Image);
}
// The method Stage2
private void Stage2(Image pbImage)
{
int skipx=0;
int skipy;
Color scolor;
int newx, newy;
newx = pbImage.Width - System.Convert.ToInt32(Math.Floor((double) (pbImage.Width/10)))-1;
newy = pbImage.Height - System.Convert.ToInt32(Math.Floor((double)(pbImage.Height/10)))-1;
// Make sure that the image isn't null first
if (pbImage != null){
Bitmap myBitmap = new Bitmap(newx , newy);
Bitmap sImage = new Bitmap(pbImage);
for (int x = 0; x < myBitmap.Width; x++)
{
if (x % 10 == 0){
skipx++;
}
else{
for (int y = 0; y < myBitmap.Height; y++)
{
skipy = 0;
if (y % 10 == 0){
skipy++;
}
else
{
scolor = sImage.GetPixel(x, y); //get color
myBitmap.SetPixel(x-skipx, y-skipy, scolor);
}
}
}
}
pictureBox3.Image = myBitmap;
}
}
}
}
Thank you in advance for your time!!!
I'll be waiting for your answers...
This is what i mean:
http://img140.imageshack.us/img140/9915/51371256.jpg (screenshot of my application)
My problem is in the third picture box (pictureBox3).All i want to do is, after pressing "Stage 2" button (stage 2 method) to eliminate the horizontal lines from there and have the resized picture...!
Reply
Answers (
12
)
List<> duplicate object problem
Backup, Detach and Attach A SQL Server Database from managed C# Code