图像算法收集贴
欢迎大家贴代码或算法,或想法,
题目自拟,题材不限
顺便BS下,不让我发三百的贴!
[解决办法]
sf
[解决办法]
其实你也不毕在C#区收集图像算法,毕竟图像算法是独立于语言的。
OpenCV是开源的,其中包括的图像处理,图像分析的算法已经很多。
一个个算法看过去,也足够你阅读个几年了。
[解决办法]
up,mark
[解决办法]
前几天回了一个帖子,重发在这里凑个热闹:)
请注意虽然它演示了利用颜色矩阵来进行色移,代码本身无关于图像算法。
using System.Drawing;using System.Windows.Forms;using System.Drawing.Imaging;public class Form1 : Form{ Bitmap bitmap = new Bitmap(500, 400); ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes(); ColorMatrix matrix = new System.Drawing.Imaging.ColorMatrix(); public Form1() { this.DoubleBuffered = true; this.ClientSize = bitmap.Size; using (Graphics g = Graphics.FromImage(this.bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bitmap.Size); } } protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawImage( this.bitmap, this.ClientRectangle, 0, 0, this.bitmap.Width, this.bitmap.Height, GraphicsUnit.Pixel, this.imageAttributes); } protected override void OnMouseMove(MouseEventArgs e) { this.matrix[4, 0] = (e.X - this.ClientRectangle.Width / 2.0f) / this.ClientRectangle.Width; this.matrix[4, 1] = (e.Y - this.ClientRectangle.Height / 2.0f) / this.ClientRectangle.Height; this.imageAttributes.SetColorMatrix(this.matrix); Invalidate(); } static void Main() { Application.Run(new Form1()); }}
[解决办法]
学习了
[解决办法]
帮顶下
[解决办法]
百叶窗效果显示图像
推拉效果显示图像
水平交错效果显示图像
垂直交错效果显示图像
图像纹理效果
图像浮雕效果
图像积木效果
马赛克效果显示图像
将彩色图片转换为灰度图片
反转图片的颜色
旋转、反射和扭曲图像
[解决办法]
此贴必火啊。
先收藏,再想想代码
[解决办法]
帮顶
[解决办法]
好主意
先帮顶了
[解决办法]
最近怎么这么多人对图形感冒了.
[解决办法]
看看这个http://www.cnpopsoft.com/article.asp?id=76,功能很强大的图片处理软件,全源码共享
[解决办法]
http://topic.csdn.net/u/20090420/00/4042e404-e802-45f7-8b25-c7fbc5a81c76.html
[解决办法]
图像算法?啥意思?
[解决办法]
学习
[解决办法]
public static bool GetThumbnailJPEG(string sourceFile,ref string destFile, int destHeight, int destWidth) { System.Drawing.Image imgSource = System.Drawing.Image.FromFile(sourceFile); int sW = 0, sH = 0; // 按比例缩放 int sWidth = imgSource.Width; int sHeight = imgSource.Height; if (sHeight > destHeight || sWidth > destWidth) { if ((sWidth * destHeight) > (sHeight * destWidth)) { sW = destWidth; sH = (destWidth * sHeight) / sWidth; } else { sH = destHeight; sW = (sWidth * destHeight) / sHeight; } } else { sW = sWidth; sH = sHeight; } Bitmap outBmp = new Bitmap(destWidth, destHeight); Graphics g = Graphics.FromImage(outBmp); g.Clear(Color.Black); // 设置画布的描绘质量 g.CompositingQuality = CompositingQuality.HighQuality; g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel); g.Dispose(); // 以下代码为保存图片时,设置压缩质量 EncoderParameters encoderParams = new EncoderParameters(); long[] quality = new long[1]; quality[0] = 100; EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality); encoderParams.Param[0] = encoderParam; try { //获得包含有关内置图像编码解码器的信息的ImageCodecInfo 对象。 ImageCodecInfo[] arrayICI = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo jpegICI = null; for (int x = 0; x < arrayICI.Length; x++) { if (arrayICI[x].FormatDescription.Equals("JPEG")) { jpegICI = arrayICI[x];//设置JPEG编码 break; } } string savefile =Path.GetDirectoryName( destFile) + "\\" + Path.GetFileName(destFile).Replace(Path.GetExtension(destFile), ".jpg"); destFile = savefile; if (jpegICI != null) { outBmp.Save(savefile, jpegICI, encoderParams); } else { outBmp.Save(savefile, ImageFormat.Jpeg); } return true; } catch { return false; } finally { imgSource.Dispose(); outBmp.Dispose(); } }
[解决办法]
还有一个类库包装类,我没写完。是DevIL的1.7.8版
中间有些C的代码不知道怎么转成C#的写法
[解决办法]
嗯,现在还没火,等着·· ···
[解决办法]
[align=left][/align]
//象素法,大概400毫秒一张private void pixel_Click(object sender, EventArgs e) { if(curBitmap != null) { myTimer.ClearTimer(); myTimer.Start(); Color curColor; int ret; for (int i = 0; i < curBitmap.Width; i++) { for (int j = 0; j < curBitmap.Height ; j++) { curColor = curBitmap.GetPixel(i,j); ret = (int)(curColor.R * 0.299 + curColor.G * 0.587 + curColor.B * 0.114); curBitmap.SetPixel(i, j, Color.FromArgb(ret, ret, ret)); } } myTimer.Stop(); timeBox.Text = myTimer.Duration.ToString("####.##") + " 毫秒"; Invalidate(); } } //内存法,大概2.5毫秒一张. private void memory_Click(object sender, EventArgs e) { if (curBitmap != null) { myTimer.ClearTimer(); myTimer.Start(); Rectangle rect = new Rectangle(0, 0, curBitmap.Width, curBitmap.Height); System.Drawing.Imaging.BitmapData bmpData = curBitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, curBitmap.PixelFormat); IntPtr ptr = bmpData.Scan0; int bytes = curBitmap.Width * curBitmap.Height * 3; byte[] rgbValues = new byte[bytes]; System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes); double colorTemp = 0; for (int i = 0; i < rgbValues.Length; i += 3) { colorTemp = rgbValues[i + 2] * 0.299 + rgbValues[i + 1] * 0.587 + rgbValues[i] * 0.114; rgbValues[i] = rgbValues[i + 1] = rgbValues[i + 2] = (byte)colorTemp; } System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes); curBitmap.UnlockBits(bmpData); myTimer.Stop(); timeBox.Text = myTimer.Duration.ToString("####.##") + " 毫秒"; Invalidate(); } } //这种方法是最快的,大概1.7毫秒一张. private void pointer_Click(object sender, EventArgs e) { if (curBitmap != null) { myTimer.ClearTimer(); myTimer.Start(); Rectangle rect = new Rectangle(0, 0, curBitmap.Width, curBitmap.Height); System.Drawing.Imaging.BitmapData bmpData = curBitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, curBitmap.PixelFormat); byte temp = 0; unsafe { byte* ptr = (byte*)(bmpData.Scan0); for (int i = 0; i < bmpData.Height; i++) { for (int j = 0; j < bmpData.Width; j++) { temp = (byte)(0.299 * ptr[2] + 0.587 * ptr[1] + 0.114 * ptr[0]); ptr[0] = ptr[1] = ptr[2] = temp; ptr += 3; } ptr += bmpData.Stride - bmpData.Width * 3; } } curBitmap.UnlockBits(bmpData); myTimer.Stop(); timeBox.Text = myTimer.Duration.ToString("####.##") + " 毫秒"; Invalidate(); } }
[解决办法]
[code=C#][/code]
[解决办法]
private void btnPictureUpLoad_Click(object sender, EventArgs e)
{
ofdPicUnload = new OpenFileDialog();
ofdPicUnload.Filter = "jpg图片|*.jpg|gif图片|*.gif|png图片|*.png";
if (ofdPicUnload.ShowDialog() == DialogResult.OK)
{
pbGoodPicture.Image = Image.FromFile(ofdPicUnload.FileName);
pbGoodPicture.Tag = Path.GetFileName(ofdPicUnload.FileName);
////保存图片到本地
//FileInfo fileInfo = new FileInfo(ofdPicUnload.FileName);
//string path = Path.GetDirectoryName(Path.GetDirectoryName(Application.StartupPath));
//string name = Path.GetFileName(ofdPicUnload.FileName);
//fileInfo.CopyTo(path + "\\Images\\UpLoadImages" + name);
}
}
[解决办法]
MARK
[解决办法]
mark
[解决办法]
学习ing~
[解决办法]
来看看,支持下
[解决办法]
留个印
[解决办法]
Up
[解决办法]
mark一下,学习!
[解决办法]
舞蝶飞数码创意
.net开发的图像处理软件。
图片合成flash
图片合成ppt
图片合成avi视频
免费照片边框
[解决办法]
mark一下
[解决办法]
收藏下~~~~~~~~~
[解决办法]
.
[解决办法]
LZ应该自己要先贴一些
[解决办法]
mark
[解决办法]
meng ding
[解决办法]
留个印
[解决办法]
大家共同研究一下数学图像算法!
[解决办法]
收藏了
[解决办法]
http://blog.csdn.net/laviewpbt/archive/2008/11/05/3229298.aspx
自动色阶算法
[解决办法]
希望有牛人能给出图像识别的算法或者源码---强人所难一直是我的乐趣。。。
[解决办法]
up,up
[解决办法]
飘过。。。
[解决办法]
//Gamma效果
public void SetGamma(double red, double green, double blue)
{
Bitmap temp = (Bitmap)_currentBitmap;
Bitmap bmap = (Bitmap)temp.Clone();
Color c;
byte[] redGamma = CreateGammaArray(red);
byte[] greenGamma = CreateGammaArray(green);
byte[] blueGamma = CreateGammaArray(blue);
for (int i = 0; i < bmap.Width; i++)
{
for (int j = 0; j < bmap.Height; j++)
{
c = bmap.GetPixel(i, j);
bmap.SetPixel(i, j, Color.FromArgb(redGamma[c.R], greenGamma[c.G], blueGamma[c.B]));
}
}
_currentBitmap = (Bitmap)bmap.Clone();
}
private byte[] CreateGammaArray(double color)
{
byte[] gammaArray = new byte[256];
for (int i = 0; i < 256; ++i)
{
gammaArray[i] = (byte)Math.Min(255, (int)((255.0 * Math.Pow(i / 255.0, 1.0 / color)) + 0.5));
}
return gammaArray;
}
[解决办法]
学习中~
[解决办法]
MARK
[解决办法]
不错啊~
[解决办法]
mark
[解决办法]
好帖,不顶一下不行呀,过不了自己.
[解决办法]
顶!~
[解决办法]
不错!顶一个
[解决办法]
路过
[解决办法]
帮顶下
[解决办法]
很好的。谢谢很好的。谢谢
[解决办法]
kanbudong
[解决办法]
希望奇迹出现:)
[解决办法]
瞅瞅...
[解决办法]
[解决办法]
学习
[解决办法]
up
[解决办法]
mark
[解决办法]
不懂。
[解决办法]
mark
[解决办法]
好,大家顶起来
[解决办法]
mark
[解决办法]
标记一下,好好学习
[解决办法]
MARK
[解决办法]
学习学习
[解决办法]
JF
[解决办法]
接分
[解决办法]
算法不分语言··· 恩
[解决办法]
收藏一下
留个脚印
[解决办法]
如果是图像处理的算法, 推荐CxImage, 功能强大, 完全开源, 用它来做一个Photoshop也不未过
http://www.codeproject.com/KB/graphics/cximage.aspx
如果是图像识别 有OpenCV tesseract之类
图像识别的开源开发包。 这个对理论的要求很高
[解决办法]
其实你也不毕在C#区收集图像算法,毕竟图像算法是独立于语言的。
OpenCV是开源的,其中包括的图像处理,图像分析的算法已经很多。
一个个算法看过去,也足够你阅读个几年了。
[解决办法]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace hough4
{
public partial class hough : Form
{
private System.Windows.Forms.Button close;
private System.Drawing.Bitmap bmpHough;
private int[,] houghMap;
private int maxHough;
public hough(Bitmap bmp)
{
InitializeComponent();
bmpHough = bmp;
maxHough = 0;
houghMap = new int[180, 180];
}
private void hough_Load(object sender, EventArgs e)
{
Rectangle rect = new Rectangle(0, 0, bmpHough.Width, bmpHough.Height);
System.Drawing.Imaging.BitmapData bmpData = bmpHough.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmpHough.PixelFormat);
IntPtr ptr = bmpData.Scan0;
int bytes = bmpHough.Width * bmpHough.Height;
byte[] grayValues = new byte[bytes];
System.Runtime.InteropServices.Marshal.Copy(ptr, grayValues, 0, bytes);
bmpHough.UnlockBits(bmpData);
Array.Clear(houghMap, 0, 32400);
for (int i = 0; i < bmpHough.Height - 1; i++)
{
for (int j = 0; j < bmpHough.Width - 1; j++)
{
if (grayValues[i * bmpHough.Width + j] == 255)
{
for (int thet = 0; thet < 180; thet++)
{
double arc = thet * Math.PI / 180;
int rho = Convert.ToInt16((j * Math.Cos(arc) + i * Math.Sin(arc)) / 8) + 90;
houghMap[thet, rho]++;
if (maxHough < houghMap[thet, rho])
maxHough = houghMap[thet, rho];
}
}
}
}
}
private void hough_Paint(object sender, PaintEventArgs e)
{
Bitmap houghImage = new Bitmap(180, 180, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
System.Drawing.Imaging.ColorPalette cp = houghImage.Palette;
for (int i = 0; i < 256; i++)
{
cp.Entries[i] = Color.FromArgb(i, i, i);
}
houghImage.Palette = cp;
Rectangle rectHough = new Rectangle(0, 0, 180, 180);
System.Drawing.Imaging.BitmapData houghData = houghImage.LockBits(rectHough, System.Drawing.Imaging.ImageLockMode.ReadWrite, houghImage.PixelFormat);
IntPtr ptr = houghData.Scan0;
int bytes = 180 * 180;
byte[] grayHough = new byte[bytes];
for (int i = 0; i < 180; i++)
{
for (int j = 0; j < 180; j++)
{
grayHough[i * 180 + j] = Convert.ToByte(houghMap[i, j] * 255 / maxHough);
}
}
System.Runtime.InteropServices.Marshal.Copy(grayHough, 0, ptr, bytes);
houghImage.UnlockBits(houghData);
Graphics g = e.Graphics;
g.DrawImage(houghImage, 40, 20, 180, 180);
g.FillRectangle(Brushes.Black, 250, 20, 180, 180);
double thresholding = maxHough * 0.6;
double k, b;
int x1, x2, y1, y2;
for (int i = 0; i < 180; i++)
{
for (int j = 0; j < 180; j++)
{
if (houghMap[i, j] > thresholding)
{
if (i == 90)
{
g.DrawLine(Pens.White, 250, 200, 250, 20);
}
else if (i == 0)
g.DrawLine(Pens.White, 250, 430, 250, 20);
else
{
k = (-1 / Math.Tan(i * Math.PI / 180));
b = ((j - 90) * 8 / Math.Sin(i * Math.PI / 180)) *180 / 512;
if (b >= 0 && b <= 180)
{
x1 = 0;
y1 = Convert.ToInt16(b);
double temp = -b / k;
if (temp <= 180 && temp >= 0)
{
x2 = Convert.ToInt16(temp);
y2 = 0;
}
else if (temp >= -180 && temp < 0)
{
x2 = Convert.ToInt16((180 - b) / k);
y2 = 180;
}
else
{
x2 = 180;
y2 = Convert.ToInt16(180 * k + b);
}
}
else if (b < 0)
{
x1 = Convert.ToInt16(-b / k);
y1 = 0;
double temp = k * 180 + b;
if (temp >= 0 && temp <= 180)
{
x2 = 180;
y2 = Convert.ToInt16(temp);
}
else
{
x2 = Convert.ToInt16((180 - b) / k);
y2 = 180;
}
}
else
{
x1 = Convert.ToInt16((180 - b) / k);
y1 = 180;
double temp = k * 180 + b;
if (temp >= 0 && temp <= 180)
{
x2 = 180;
y2 = Convert.ToInt16(temp);
}
else
{
x2 = Convert.ToInt16(-b / k);
y2 = 0;
}
}
g.DrawLine(Pens.White, x1 + 250, y1 + 20, x2 + 250, y2 + 20);
}
}
}
}
g.DrawString("Hough变换映射图像", new Font("Arial", 8), Brushes.Black, 80, 210);
g.DrawString("Hough反变换图像", new Font("Arial", 8), Brushes.Black, 290, 210);
}
}
}
hough 变换的c#实现,参考人民邮电出版社的新书