多图像图像处理问题 [英] Multiple Images Image Processing Issues

查看:65
本文介绍了多图像图像处理问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

首先,我要感谢所有如此合作的人.我已经两次寻求帮助,我已经两次获得帮助,谢谢.

第二,我的问题.我正在研究图像处理程序.在此程序中,我可以选择多个图像.另外,我添加了一些图像处理工具,例如亮度和对比度.现在,这就是问题所在.例如,当我一次打开说4张图像,然后更改第一张图片的亮度时,它可以正常工作.但是,当我转到第二张图片并更改其亮度时,该图片会完全变为第一张图片,然后再次调整第一张图片的亮度,但要在第二张图片的位置进行调整,然后再调整其余图片也会发生相同的情况.就像我选择6张多张图片一样,所有6张图片都被命名为第一张选中的图片.所以也许这就是为什么当我调整其他图像时它们会变为第一张图像.

这是我用来打开多个图像的代码:

Hello everyone!

First if of all, I would like to say thank you to everyone who for being so cooperative. I''ve asked for help twice and I have received helped twice so thank you.

Second all, my question. I''m working on an image processing program. In this program, I can select multiple images. Also, I added some image processing tools like brightness and contrast. Now, here''s the problem. For example, when I open say 4 images at once and then change the brightness of the first picture, it works fine. But, then when I go to the second picture and then change it''s brightness, the picture changes completely to the first picture and then the brightness of the first picture is adjusted again but in the second picture''s position and then the same thing happens to the rest of the pictures. it''s like if I choose 6 multiple images, all 6 images are named as the first selected image. So maybe that''s why when I adjust other images they changed to the first image.

Here''s the code I''m using for opening multiple images:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
.......
.......

namespace Filters
{
    public partial class Form1 : Form
         
    {
        private static int imageCount;
        private static int totalImageCount;
...........
...........
..........


    private void openToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                open.Multiselect = true;
                open.Filter = "Image Files (*.tif; *.dcm; *.jpg; *.jpeg)|*.tif; *.dcm; *.jpg; *.jpeg";

                if (open.ShowDialog() == DialogResult.OK)
                {
                    int i = 0;
                    totalImageCount = open.FileNames.Length;
                    images = new Image[totalImageCount];
                    foreach (String file in open.FileNames)
                    {
                        images[i] = Image.FromFile(file);
                        i++;
                    }
                    picShowPicture.Image = images[imageCount];
                    if (totalImageCount > 0)
                    {
                        nextBtn.Enabled = true;
                        open.CheckFileExists = true;
                        open.CheckPathExists = true;
                    }

                    imageOfTxt.Text = "Image 1 of " + totalImageCount;
                }
            }
            catch (Exception)
            {
                throw new ApplicationException("Failed loading image");
            }
            myImage = (Bitmap)picShowPicture.Image;
            newBitmap = new Bitmap(open.FileName);
        }



因此,是否有可能我们可以选择多张图像并将每张图像当作自己的图片使用,而无需使用其他图像的名称或像我给您的示例一样?

谢谢大家:D



So is it possible that we can select multiple images and have each image to be treated as a picture of its own without taking another image''s name or like the example I gave you?

Thank you everyone :D

推荐答案



好吧,我希望您的编码有些混乱.您拥有的代码确实将所有Image都成功加载到一个数组中.我希望您的错误是由于未将更改的图像保存回此数组而引起的.我在您的代码中添加了三个按钮,以便我可以有效地检查您的代码.有两个我知道您已经在image [n]数组中进行了哪个循环.

Hi,

Well I expect you have messed up a little in your coding. The code you have does successfully load all you Image into an array. I expect your error is coming from not saving the changed image back into this array. I''ve added three button two your code so I could effectively check your code. Two I know you already have which cycle through your images[n] array.

private void nextBtn_Click(object sender, EventArgs e)
{
    if (images.Length - 1 > imageCount)
    {
        imageCount++;
        pictureBox1.Image = images[imageCount];
    }
    this.Refresh();
}


private void PrevBtn_Click(object sender, EventArgs e)
{
    if (imageCount > 0)
    {
        imageCount--;
        pictureBox1.Image = images[imageCount];
    }
    this.Refresh();
}



现在,在这种情况下,我添加了三分之一,只是将图像效果更改为灰度效果.在这里,您将拥有用于调整亮度等的代码.



Now I added a third in this case all I did was change the image effect into a grayscale one. Here you would have your code to adjust brightness etc.

private void Grey_BTN_Click(object sender, EventArgs e)
{
   Bitmap myImage = (Bitmap)pictureBox1.Image;

   for (int y = 0; y < myImage.Height; y++)
   {
       for (int x = 0; x < myImage.Width; x++)
       {
            Color c = myImage.GetPixel(x, y);
            int luma = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);
            myImage.SetPixel(x, y, Color.FromArgb(luma, luma, luma));
       }
   }
    
   //Here is the important bit of storing your changes
   images[imageCount] = myImage; 
   pictureBox1.Image = images[imageCount];
   this.refresh();
}



希望对您有帮助
让我知道是否需要更多助手,以及是否需要高级图像处理功能,那么我建议EMGU为OpenCV图像处理库提供C#包装.

保重
克里斯



I hope this helps
Let me know if you need more assistant, and if you need mor advanced image processing features then I suggest EMGU a C# wrapper for the OpenCV image processing library.

Take Care
Chris


这篇关于多图像图像处理问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆