2018년 9월 27일 목요일

기계시각의 이미지 프로세싱 #001

1. 영상의 이진화

    임계값, threshold, 문턱값, 기준값을 이용하여 영상의 모든 픽셀을 검사하여 문턱값보다 높을 경우 1, 낮을 경우 0 으로 하는 이진 영상(binary image)를 만들어 내는 것. 매트랩에서는 영상의 이진화를 im2bw 라는 함수를 이용하여 간단히 수행.

img = imread('2.bmp');
BW = im2bw(img,0.5);  ! 0.5 = 127.5 값
s  = regionprops(BW,'centroid');
centroids = cat(1, s.Centroid);
imshow(BW);
hold on;
plot(centroids(:,1), centroids(:,2), 'b*');
hold off;



2.  영상 이진화(binarization, thresholding)
   영상의 밝기 분포를 보고 임계값을 찾아주는 방법 Otzu's method (N. Otsu, “A threshold selection method from gray-level histograms,” IEEE Trans. Syst., Man, Cybern., vol. SMC-9, pp. 62-66, 1979).   임계값을 0-255까지 변화시켜  밝기평균의 차의 제곱의 최대값을 찾는 방법.

2018년 6월 12일 화요일

솔릳웍스 2015 sim disabled 현상

https://hawkridgesys.com/blog/solidworks-and-windows-update-alert-solution


Instability in SOLIDWORKS due to conflict with Microsoft KB3072630

Summary

There is a conflict with Microsoft KB3072630 (published July 14 2015) which can cause SOLIDWORKS to become unstable when installed or updated after KB3072630 is applied. The Microsoft update makes changes to Windows Installer which prevents SOLIDWORKS installations (new, modify/repair, update or uninstall) from being executed correctly. We are working diligently to produce a software fix as soon as possible in SOLIDWORKS 2015 and 2016, however in the interim please review the information below to prevent and correct instability caused by this conflict.

2018년 3월 12일 월요일

CFileDialog에서 여러 파일을 다루는 부분

255개 이상의 파일의 이름을 가져오려고 했는데 그 이상은 에러.

 CFileDialog dlg(TRUE, "", NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_LONGNAMES | OFN_ALLOWMULTISELECT, szFilter, NULL);

 char filename[10000] = {0};
 dlg.m_ofn.lpstrFile = filename;
 dlg.m_ofn.nMaxFile = 10000-1;

  여기서 첫번째 오류   LEESH







좀더 찾아보니.

    기본적으로 2048 버퍼 사이즈로 설정이 되어 있기 때문에

     보통 20개 글자라고 하면...  2048/20 정도만 올라옴.

그래서,  위와 같이 늘려주었는데,   10,000 사이즈로 버퍼를 잡았으니,

  글자수가 40개 이면,,,    250개 정도 파일만 다루게 됨.  따라서,


  CFileDialog dlgFile(TRUE);
  CString fileName;
  const int c_cMaxFiles = 10000;
  const int c_cbBuffSize = (c_cMaxFiles * (MAX_PATH + 1)) + 1;
  dlgFile.GetOFN().lpstrFile = fileName.GetBuffer(c_cbBuffSize);
  dlgFile.GetOFN().nMaxFile = c_cMaxFiles;

   이렇게 해줘야 10000개정도 다룰수 있음.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/828d548e-2c9b-460f-8138-339e2d557878/cfiledialog-and-ofnallowmultiselect?forum=vcgeneral

2018년 2월 26일 월요일

Octave 옥타브 matlab 대안으로 USB4000 데이터를 읽어본다.

Octave 4.2.1  은 javaaddpath가 가능하다.


>> javaaddpath('C:\Program Files\Ocean Optics\OmniDriver\OOI_HOME\OmniDriver.jar');
>> wrapper = com.oceanoptics.omnidriver.api.wrapper.Wrapper();
>> wrapper.openAllSpectrometers();

"error: 'com' undefined",

>> wrapper = javaObject ("com.oceanoptics.omnidriver.api.wrapper.Wrapper")


>> spectrum = wrapper.getSpectrum(0);
>> wavelengths = wrapper.getWavelengths(0);

>> plot(wavelengths, spectrum);