#include <stdio.h>


#pragma warning(disable: 4996)


int main(){

FILE *pFile;

pFile = fopen("MakeAFile.txt", "w");

if ( pFile != NULL ){

fputs("fopen example", pFile);

fclose(pFile);

}


return 0;

}

#include <opencv\cv.h>

#include <opencv\highgui.h>


using namespace cv;

using namespace std;


int main(){


// 이미지 불러오기 (read image).

Mat image = imread("image.jpg");


// 에러 처리 (error).

if ( !image.data ) {

return -1;

}


// 관심영역 설정 (set ROI (X, Y, W, H)).

Rect rect(100, 30, 150, 300);


// 관심영역 자르기 (Crop ROI).

Mat subImage = image(rect);


// show

imshow("image", subImage);


waitKey(0);


return 0;

}



#include <opencv2/opencv.hpp>

using namespace cv;


int main(int argc, char **argv){

char *imageName = argv[1];


Mat image;

image = imread(imageName, 1);    // 이미지 불러오기.


// 에러 처리.

if ( argc!= 2 || !image.data ){

printf(" No image data \n ");

return -1;

}


// 불러온 이미지와 구분하기 위하여 흑백 이미지로 변환.

Mat grayImage;

cvtColor( image, grayImage, COLOR_BGR2GRAY );


// 파일명 "GrayImage.jpg"로 저장.

imwrite( "GrayImage.jpg", grayImage );


return 0;

}


이와같이 사용하시면 이미지 불러오기와 저장을 할 수 있습니다.

'STUDY > Android' 카테고리의 다른 글

Android 개발환경 설정하기 1  (0) 2013.11.25
  • 다음의 링크를 클릭하신 후에 사용자 환경에 맞는 프로그램을 다운 받으시면 됩니다.

https://www.gnu.org/software/octave/download.html




  • 먼저 homebrew와 XQuartz 설치를 합니다. (설치 되어있으시면, 다음 단계로 넘어가시면 됩니다. )

    $ curl http://xquartz-dl.macosforge.org/SL/XQuartz-2.7.7.dmg -o /tmp/XQuartz.dmg

    $ open /tmp/XQuartz.dmg

    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


  • homebrew와 XQuartz 설치 후 아래의 명령어를 입력하여 Octave 설치하자.
    • $ brew tap homebrew/science

      $ brew update && brew upgrade

      $ brew install gcc

      $ brew install octave

  • Octave가 설치 완료가 되었습니다. 일반적으로 터미널에서 octave 명령어를 입력하면 바로 실행이 됩니다. 그렇지 않으신분들은 다음 경로로 이동하여 실행하시면 됩니다. (
    /usr/local/Cellar/octave/3.8.1_1/bin/octave)


  • Octave를 실행시키고 "1+1"를 실행한 결과 화면 입니다.

    모두들 Octave와 즐거운 시간 가지세요~


      'STUDY > Octave' 카테고리의 다른 글

      Octave 란?  (0) 2016.02.11

      • 맥에서 XQuartz 설치하는 방법은 아래와 같다.
        • 첫번째로, 터미널을 실행한 후, 다음과 같이 입력한다.
        • $ curl http://xquartz-dl.macosforge.org/SL/XQuartz-2.7.7.dmg -o /tmp/XQuartz.dmg

          $ open /tmp/XQuartz.dmg

        • 두번째로 파인터 (Finder)에서 XQuartz를 더블클릭한다.

          • "계속" 클릭.

          • "계속" 클릭.

          • "계속" 클릭.

          • "동의" 클릭.

          • "설치" 클릭.

          • 암호 입력 후, "소프트웨어 설치" 클릭.

          • (설치가 완료 되었습니다.) "닫기" 클릭.

          • (설치가 완료 되었기 때문에 XQuartz를 제거 한다.) 파인더 (Finder) 에서 XQuartz 제거.



      'STUDY > Mac' 카테고리의 다른 글

      [mac] 맥 파인더 미리보기 ( preview mac finder )  (0) 2016.10.29
      Xcode란??  (0) 2013.01.09

      옥타브 (Octave) 는 수치해석용 자유컴퓨터 소프트 웨어로서, MATLAB과 호솬성이 높다.

      옥타브는 GNU 프로젝트의 하나이다.

      옥타브는 매스매티카 같은 컴퓨터 대수 체계가 아니라 과학적 계산을 위한 도구이다.

      제일 중요한건 Octave는 무료이다.

      자세한 내용은 여기 (here).

      'STUDY > Octave' 카테고리의 다른 글

      옥타브 (Octave) 설치  (0) 2016.02.11

      What is Unix ?

      UNIX 운영 시스템은 프로그램들의 집합이다. 이 프로그램들은 컴퓨터와 사용자들을 연결해주는것과 같이 행동한다.

      시스템 자원과 컴퓨터 내부의 모든 자세한 위치를 할당하는 컴퓨터 프로그램은 운영시스템 및 커널(kernel) 이라고 불려진다.

      사용자들과 커널은 잘알려진 쉘 (shell)과 같은 프로그램을 통해서 의사소통한다. 쉘은 한 명령어 줄을 번역한다. 사용자에의한 명령어 입력이 커널이 이해하기 위한 언어로 변환된다.

        • Unix 는 1969년 AT&T의 직원 Bell Labs, Ken Thompson, Dennis Ritchie, Douglas McIlroy와 Joe Ossanna에 의해서 처음 개발되어졌다.

        • 다양한 Unix는 이 분야에서 다양하게 이용가능하다.  Solaris unix, AIX, HP Unix와 BSD이 대표적인 예제들이다. 리눅스 (Linux) 또한 Unix를 무료로 사용할 수 있는 방법이다.
        • 몇 몇 사람들은 동시에 한 UNIX컴퓨터를 사용할 수 있다. 따라서 Unix는 멀티 시스템이라고 불려진다.
        • 한 사용자는 또한 동시에 여러개의 프로그램을 실행시킬수 있어서 멀티 작업자라고도 불려진다.

      Unix Architecture

      여기 UNIX 시스템 기본 블럭 다이어그램이다.

      주요 개념은 UNIX의 모든 버전들은 아래 네개가 기본이다.

        • Kernel : 커널 (kernel)은 운영시스템의 심장이다. 

      'STUDY > UNIX' 카테고리의 다른 글

      [Terminal] 새로운 파일 생성 (Creating New File)  (0) 2016.12.07
      UNIX Tutorial  (0) 2016.02.06

      1. UNIX 지도서
        1. UNIX는 컴퓨터 운영체제 입니다. 이 운영체제는 동시에 여러명의 사용자가 사용할 수 있습니다. UNIX는 1969년 AT&T 벨 연구실 Ken Thompsom 과 Dennis Ritchie 시작하였습니다.
      2. 대상
        1. 이 지도서는 초보자들이 기본적이고 앞선 Unix 명령어들, 쉘 스크립팅과 다양한 유틸리티들을 이해를 도와주기 위해서 준비되었습니다.
      3. 사전에 필요한 것들
        1. 우리는 독자분들이 운영체제와 컴퓨터 기능에대한 기본 지식을 가지고 있을것이라 추측합니다. 다양한 컴퓨터상에 기본 지식은 독자분들의 이 기본 지도서에서 다양한 연습을통한 이해에 도움을 줄것입니다.
      4. Unix 쉘 프로그램 실행
        1. 만약 독자분들이 Unix/Linux 기본 명령어들과 쉘 스크립트를 배우기 원한다면, Unix/Linux를 설치하지 않으셔도 됩니다. CodingGround 에서 높은 수준의 서버를 독자분들의 프로그래밍 경험을 제공해드립니다. 이것은 무료이며 온라인에서만 제공해드립니다.



      'STUDY > UNIX' 카테고리의 다른 글

      [Terminal] 새로운 파일 생성 (Creating New File)  (0) 2016.12.07
      What is Unix?  (0) 2016.02.10

      #include <iostream>
      #include <cstdio>
      #include <stdio.h>
      #include <map>
      #include <iterator>
      #include <string>
      #include <fstream>
      #include <dirent.h>
      #include <sys/types.h>
      #include <sys/stat.h>
      #include <strings.h>
      #include <memory.h>
      #include <stdlib.h>

      using namespace std;

      typedef map<string, bool> FILE_LIST;

      class CFileList
      {
      public:
          CFileList();
          ~CFileList();

      public:
          bool GetFileList(FILE_LIST& list, string strDir); //디렉토리 및 파일목록을 구한다
          void ShowFileList(FILE_LIST& list);//리스트를 출력한다
      };

      CFileList::CFileList()
      {
      }

      CFileList::~CFileList()
      {
      }

      bool CFileList::GetFileList(FILE_LIST& list, string strDir)
      {
          struct stat statinfo;
          memset(&statinfo, 0, sizeof(statinfo));
          lstat(strDir.c_str(), &statinfo);
          if(!S_ISDIR(statinfo.st_mode))
          {
              cout<<strDir + " is not directory"<<endl;
              return false;
          }

          DIR *dir;
          struct dirent *entry;

           if ((dir = opendir(strDir.c_str())) == NULL)
           {
               cout<<strDir + " open error"<<endl;
              return false;
           }

          while ((entry = readdir(dir)) != NULL)
          {
              memset(&statinfo, 0, sizeof(statinfo));
              string strFilePath = strDir + "/" + entry->d_name;
              while(strFilePath.find("//") != string::npos)
                      strFilePath.replace(strFilePath.find("//"), 2, "/");

              lstat(strFilePath.c_str(), &statinfo);

              if(S_ISDIR(statinfo.st_mode)) // 디렉토리 이면
              {
                  if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
                      continue;

                  list.insert(pair<string, bool>(strFilePath, true)); //디렉토리 경로를 넣음

       
                  string strSubDir = strDir + "/" + entry->d_name;
                  GetFileList(list, strSubDir); //디렉토리 안으로 들어감
              }
              else
              {
                  //파일이면
                  list.insert(pair<string, bool>(strFilePath, false)); //파일경로를 넣음
              }
          }

          //읽은 디렉토리 닫기
           closedir(dir);

          return true;
      }

      void CFileList::ShowFileList(FILE_LIST& list)
      {
          //  특정 폴더 위치
          char path[] = "/media/HP01049471071/2015Y/Image/"; 
         
          FILE_LIST::iterator itr;
          cout << "[ShowFileList] : " << endl;
          for(itr = list.begin(); itr != list.end(); itr++)
          {
              if ( itr->second == true )
              {  
                  //  exclude directory
                  cout<<"[DIRECTORY] " + itr->first<<endl;
              }
              else
              {
                  //  string to char
                  char *fileName = new char[(itr->first).length()+1];
                  strcpy(fileName,(itr->first).c_str()); 
                 
                  //  Make a command sentence
                  char cmd[1024];
                  sprintf(cmd, "mv %s %s", fileName, path );
                  sprintf(cmd, "cp %s %s", fileName, path );

                  //  move / copy
                  system(cmd);

                  //  release
                  free(fileName);
              }
          }
      }

      int main(int argc, char* argv[])
      {
          if(argc != 2)
          {
              cout<<"usage: filelist [directory path]"<<endl;
              return 1;
          }

          CFileList FileList;

          string strSrcDir = argv[1];

          FILE_LIST file_list;

          FileList.GetFileList(file_list, strSrcDir);
          FileList.ShowFileList(file_list);

          return 0;
      }

      + Recent posts