This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// opencvを使わないプログラム。ただしppm形式の画像を見られるソフトが必要。 | |
// 実行する際は"input.ppm"というファイル名の画像データを用意する。 | |
#include <fstream> | |
#include <sstream> | |
#include <string> | |
#include <stdlib.h> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: UTF-8 | |
from PIL import Image | |
# 画像を取得 | |
image = Image.open('input.png', 'r').convert('L') | |
# サイズを取得 | |
width, height = image.size | |
# 出力画像を生成 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
namespace image_filter | |
{ | |
class MainClass | |
{ | |
public static Byte getGrayScale(Color c) | |
{ | |
return (Byte)((c.A + c.G + c.B) / 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.image.BufferedImage; | |
import java.io.*; | |
import javax.imageio.ImageIO; | |
public class ImageFilter { | |
/** | |
* RGBで表される画素をグレースケールの画素へ変換します。 | |
* @param rgb RGBで表される画素 | |
* @return グレースケールの画素 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 線形フィルタの動作確認用プログラム | |
// 実行する際は"input.png"というファイル名の画像データを用意する。 | |
//#include <cstdint> visual studio2008だとインクルードできないのでコメントアウト | |
#include <opencv2/opencv.hpp> | |
#include <opencv2/core/core.hpp> | |
#include <opencv2/highgui/highgui.hpp> | |
typedef unsigned char uint8_t; //cstdintがインクルードできないときはuint8_tをtypedefする | |