1월, 2018의 게시물 표시

[C#] Bitmap to 2D Array

double [,] yarray; yarray = new double [160,140]; Bitmap LLL = new Bitmap ( "c:/ProtoA/rL.jpg" ); for (ix = 0; ix < 160; ix++) { for (iy = 0; iy < 140; iy++) { yarray[ix, iy] = .299 * LLL.GetPixel(ix, iy).R + .587 * LLL.GetPixel(ix, iy).G + .114 * LLL.GetPixel(ix, iy).B; } }

3.bmp SSM

이미지
import numpy as np import cv2 WIDTH = 128   # has a great influence on the result if __name__ == '__main__':     img = cv2.imread('/home/jonathan/Pictures/3.bmp', 0)     img = cv2.resize(img, (WIDTH, WIDTH*img.shape[0]/img.shape[1]))     c = cv2.dft(np.float32(img), flags = cv2.DFT_COMPLEX_OUTPUT)     mag = np.sqrt(c[:,:,0]**2 + c[:,:,1]**2)     spectralResidual = np.exp(np.log(mag) - cv2.boxFilter(np.log(mag), -1, (3,3)))     c[:,:,0] = c[:,:,0] * spectralResidual / mag     c[:,:,1] = c[:,:,1] * spectralResidual / mag     c = cv2.dft(c, flags = (cv2.DFT_INVERSE | cv2.DFT_SCALE))     mag = c[:,:,0]**2 + c[:,:,1]**2     cv2.normalize(cv2.GaussianBlur(mag,(9,9),3,3), mag, 0., 1., cv2.NORM_MINMAX)     cv2.imshow('Saliency Map', mag)     c = cv2.waitKey(0) & 0xFF         if(c==27 or c==ord('q')):         cv2.destroyAllWindows()

LenaColor + SSM + Python2 + Ubuntu + OCV2

이미지
import numpy as np import cv2 WIDTH = 128   # has a great influence on the result if __name__ == '__main__':     img = cv2.imread('/home/jonathan/Pictures/lena.bmp', 0)     img = cv2.resize(img, (WIDTH, WIDTH*img.shape[0]/img.shape[1]))     c = cv2.dft(np.float32(img), flags = cv2.DFT_COMPLEX_OUTPUT)     mag = np.sqrt(c[:,:,0]**2 + c[:,:,1]**2)     spectralResidual = np.exp(np.log(mag) - cv2.boxFilter(np.log(mag), -1, (3,3)))     c[:,:,0] = c[:,:,0] * spectralResidual / mag     c[:,:,1] = c[:,:,1] * spectralResidual / mag     c = cv2.dft(c, flags = (cv2.DFT_INVERSE | cv2.DFT_SCALE))     mag = c[:,:,0]**2 + c[:,:,1]**2     cv2.normalize(cv2.GaussianBlur(mag,(9,9),3,3), mag, 0., 1., cv2.NORM_MINMAX)     cv2.imshow('Saliency Map', mag)     c = cv2.waitKey(0) & 0xFF         if(c==27 or c==ord('q')):         cv2.destroyAllWindows()

Run python script in Winform

Hello from Python Call Dir(): [] Print the Path: ['.', 'c:\\users\\bemor\\source\\repos\\wfIronPy1\\wfIronPy1\\bin\\Debug\\Lib', 'c:\\users\\bemor\\source\\repos\\wfIronPy1\\wfIronPy1\\bin\\Debug\\DLLs']

winformPictureBox with ironPython

이미지
#!/usr/bin/ipy import sys import clr clr.AddReference("System.Windows.Forms") clr.AddReference("System.Drawing") from System.Windows.Forms import Application, Form, PictureBox from System.Drawing import Size, Point, Bitmap class IForm(Form):     def __init__(self):         self.Text = 'PictureBox'                 try:             castle = Bitmap('lena512.bmp')         except Exception, e:             print 'Cannot read image file'             print e.msg             sys.exit(1)         pb = PictureBox()         pb.Parent = self         pb.Size = Size(castle.Width, castle.Height)         pb.Location = Point(2, 2)         pb.Image = castle         self.Size = Size(castle.Width, castle.Height)         self.CenterToScreen() Application.Run(IForm())

RadioButton by ironPython

이미지

ironPython + Winform

http://www.voidspace.org.uk/ironpython/winforms/

batch file processing by C#

// For Directory.GetFiles and Directory.GetDirectories // For File.Exists, Directory.Exists using System; using System.IO; using System.Collections; public class RecursiveFileProcessor { public static void Main( string [] args) { foreach ( string path in args) { if (File.Exists(path)) { // This path is a file ProcessFile(path); } else if (Directory.Exists(path)) { // This path is a directory ProcessDirectory(path); } else { Console.WriteLine( "{0} is not a valid file or directory." , path); } } } // Process all files in the directory passed in, recurse on any directories // that are found, and process the files they contain. public static void ProcessDirectory( string targetDirector

batch image processing by Python

#!/usr/bin/python import os import re from scipy import ndimage, misc images = [] for root, dirnames, filenames in os.walk("."):    for filename in filenames:      if re.search("\.(jpg|jpeg|png)$", filename):        filepath = os.path.join(root, filename)        image = ndimage.imread(filepath, mode="L")        image_resized = misc.imresize(image, (256, 256))        misc.imsave(filepath, image_resized)

Histogram Matching by Python

http://vzaguskin.github.io/histmatching1/

spectral saliency by python

https://github.com/uoip/SpectralResidualSaliency/blob/master/src/saliency.py

ironPython+Winform

https://gist.github.com/gtalarico/9fc493e0a889d3ae66b2bd236423d087

ironPython + C#

https://www.codeproject.com/Articles/602112/Scripting-NET-Applications-with-IronPython

Accord.Extension.Imaging.Algorithms

Implements image-processing and computer-vision algorithms.       Provides extensions for image-processing algorithms implemented in Accord.NET framework and for some image-processing algorithms implemented in AForge.NET framework. https://github.com/dajuric/accord-net-extensions.github

Accord.Datasets

Contains classes to download and parse machine learning datasets such as MNIST, News20, Iris. This package is part of the Accord.NET Framework.

Co-saliency Map Papers

http://hzfu.github.io/proj_cosal_review.html

freq_diffusion.m

function r=freq_diffusion(p,l,t) #freq_diffusion(gaussian1d(100,50,5),0.5,100); n=length(p); q0=fft(p); Q=q0; g=[1-l,l/2,zeros(1,n-3),l/2]'; G=fft(g); #[X,T]=meshdom(1:n,1:t); for n=1:(t-1) q=q0.*(G.^n); # Q=[q,Q]; plot(1:length(q),sqrt(real(q).^2+imag(q).^2)); end #mesh(T,X,norm(Q')); r=ifft(q);

markov3.m

function [P,v]=markov3(a,b,c,d,e,f,x0,y0) P=[a, b, c; d e f; 1-a-d, 1-b-e, 1-c-f]; x(1:50) = 0; y(1:50) = 0; z(1:50) = 0; v(1) = x0; v(2) = y0; v(3) = 1-x0-y0; for n=1:50 x(n) = v(1); y(n) = v(2); z(n) = v(3); v=P*v; end mplot(1:50,x,1:50,y,1:50,z);

histogram.m

function h=histogram(f,N) % histogram - computes a grey level histogram. % version 1 % Lance Williams % Dept. of Computer Science % Univ. of New Mexico % h(1:N) = 0; rf=size(f,1); cf=size(f,2); for i=0:N-1 h(i+1) = sum(sum(f==i)); end

Co-Saliency Map by Matlab

https://github.com/HzFu/Cosaliency_tip2013.git