| | |
merging image
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 4
Reputation:
Solved Threads: 0
hi i have created a code that allows images from 5 picboxes to merge together.
but i have a problem distinguishing them.
after merging, i would want to have different greyscale values for the images merged into one picbox.
my image is made up of black and white only. thus, the image of the black image(which are actually dots) to have different pixel value. BUT, it must still be a shade of black.
this is the code that i am working on:
pls help.
but i have a problem distinguishing them.
after merging, i would want to have different greyscale values for the images merged into one picbox.
my image is made up of black and white only. thus, the image of the black image(which are actually dots) to have different pixel value. BUT, it must still be a shade of black.
this is the code that i am working on:
C# Syntax (Toggle Plain Text)
public Bitmap mergeImages(Bitmap[] images) { Bitmap mergedImg = new Bitmap(images[0].Width, images[0].Height); for (int h = 0; h < mergedImg.Height; h++) { for (int w = 0; w < mergedImg.Width; w++) { Color c = images[0].GetPixel(w, h); if (c.R == 255 && c.G == 255 && c.B == 255) { int index = 1; for (; index < images.Length; index++) { if (images[index].GetPixel(w, h) == c) continue; else break; } if (index == images.Length) { //all the pixel in the same location in all images are all white mergedImg.SetPixel(w, h, c); } else { //if not, set the color of the pixel to be black; Color c1 = Color.FromArgb(0, 0, 0); mergedImg.SetPixel(w, h, c1); } } else { Color c1 = Color.FromArgb(0, 0, 0); mergedImg.SetPixel(w, h, c1); } } } return mergedImg; }
for those tasks, I recommend to use MATLAB it helps a lot and has a lot of built in algorithms and toolbox you can use, use its funcationality then make your work as dll and call it from C# application
Last edited by Ramy Mahrous; Sep 24th, 2007 at 7:27 pm.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Sep 2008
Posts: 16
Reputation:
Solved Threads: 0
I was just trying to make the same thing. It took me a while but I got it.
Hope this helps
Hope this helps
C# Syntax (Toggle Plain Text)
/// <summary> /// Merges 4 Images into 1 Image. /// </summary> /// <param name="image1">The Image you want in the Top-Left Corner.</param> /// <param name="image2">The Image you want in the Top-Right Corner.</param> /// <param name="image3">The Image you want in the Bottom-Left Corner.</param> /// <param name="image4">The Image you want in the Bottom-Right Corner.</param> /// <returns>An Image of 4</returns> public Image MergeImages(Image image1, Image image2, Image image3, Image image4) { //Get the Width of All the Images Int32 width = image1.Width + image2.Width + image3.Width + image4.Width; //Get the Height of All the Images Int32 height = image1.Height + image2.Height + image3.Height + image4.Height; //Create a new Bitmap with the Width and Height Bitmap bitmap = new Bitmap(width, height); //Get All of the x Pixels for (int w = 0; w < image1.Width; w++) { //Get All of the Y Pixels for (int h = 0; h < image1.Height; h++) { //Create a new Bitmap from image1 Bitmap image = new Bitmap(image1); //Set the Cooresponding Pixel bitmap.SetPixel(w, h, image.GetPixel(w, h)); } } //Get All of the x Pixels for (int w = 0; w < image2.Width; w++) { //Get All of the Y Pixels for (int h = 0; h < image2.Height; h++) { //Create a new Bitmap from image2 Bitmap image = new Bitmap(image2); //Set the Cooresponding Pixel bitmap.SetPixel(image.Width + w, h, image.GetPixel(w, h)); } } //Get All of the x Pixels for (int w = 0; w < image3.Width; w++) { //Get All of the Y Pixels for (int h = 0; h < image3.Height; h++) { //Create a new Bitmap from image3 Bitmap image = new Bitmap(image3); //Set the Cooresponding Pixel bitmap.SetPixel(w, image.Height + h, image.GetPixel(w, h)); } } //Get All of the x Pixels for (int w = 0; w < image4.Width; w++) { //Get All of the Y Pixels for (int h = 0; h < image4.Height; h++) { //Create a new Bitmap from image4 Bitmap image = new Bitmap(image4); //Set the Cooresponding Pixel bitmap.SetPixel(image.Width + w, image.Height + h, image.GetPixel(w, h)); } } //Return the new Bitmap return bitmap; }
Last edited by gbertoli3; Oct 19th, 2008 at 7:59 pm.
![]() |
Similar Threads
- How to create image maps that look so nice... (Graphics and Multimedia)
- Image capture into HTML/IE and Oracle databases... (Oracle)
- adobe image problem (Graphics and Multimedia)
- Webcam stops transmitting image (USB Devices and other Peripherals)
- IE "Save Image as;" Bitmap, wont in JPEG??? (Web Browsers)
- cant use acronis true image on windows xp (Windows NT / 2000 / XP)
- edit text on a gif image in photoshop (Graphics and Multimedia)
Other Threads in the C# Forum
- Previous Thread: Angle conversions
- Next Thread: have a problem with inheritance
| Thread Tools | Search this Thread |
.net access ado.net algorithm animation array barchart bitmap box broadcast buttons c# check checkbox client color combobox control conversion cs4 csharp custom database datagrid datagridview dataset datastructure datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label linux list listbox listener mandelbrot math mouseclick mysql operator packaging path photoshop picturebox pixelinversion post powerpacks programming radians regex remote remoting richtextbox serialization server sleep socket sql statistics stream string study table tcp text textbox thread time timer tutorial update usercontrol validation visualstudio webbrowser wia windows windowsformsapplication winforms wpf xml






