แสดงบทความที่มีป้ายกำกับ filter แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ filter แสดงบทความทั้งหมด

วันศุกร์ที่ 21 เมษายน พ.ศ. 2560

Show Circular Masks การสร้าง Mask สำหรับ filter

Show Circular Masks…


สร้าง stack ที่ประกอบเป็น circular mask ด้วย Media..., Mean..., Minimum..., Maximum..., และ Variance... สำหรับเป็น filter ของขนาดรอบข้าง

ตัวอย่าง



การเรียกใช้เมนู


ผลลัพธ์





การเพิ่มความคมชัดของขอบภาพด้วยวิธีการ Unsharp Mask

Unsharp Mask…


การทำขอบให้มีความชัดขึ้นด้วยการลบ pixel ด้วยภาพเดิมในรูปแบบการสร้างภาพเบลอ (the unsharp mask) กับภาพต้นฉบับ


ตัวอยาง



การเรียกเมนู



ผลลัพธ์



Raises  เป็นค่าเบี่ยงเบนมาตรฐาน (sigma blur radius) ของ Gaussian หากเพิ่มค่า Gaussian blur radius จะเป็นการเพิ่มค่า contrast

Mask Weight พิจารณาข้อดีของการทำ filtering เมื่อ Mask Weight = 1 จะเป็นค่าน้ำหนักที่ไม่มีขอบเขตของการทำ filter แบบ high-pass filter หากมีการเพิ่มค่า Mask Weight จะทำให้เส้นขอบมีประสิทธิภาพมากขึ้น



การลบค่าระดับเทา ด้วยค่า Maximum

Maximum…


ตัวกรอง (filter) นี้ใช้ในการลบค่าระดับเทาด้วยการแทนที่ pixel ของภาพด้วยค่าที่มากที่สุดของ pixel รอบข้าง


ตัวอย่าง



การเรียกใช้เมนู



ผลลัพธ์






การลดค่าระดับเทา ด้วยค่า Minimum ของภาพ

Minimum…


ตัวกรอง (filter) นี้ใช้ในการลดค่าระดับเทาของภาพ ด้วยการแทนที่ pixel ของภาพ ด้วยค่าที่น้อยที่สุดของ pixel รอบข้าง


ภาพตัวอย่าง



การเรียกใช้เมนู



ผลลัพธ์





สร้างความนุ่มนวลให้ภาพด้วย filter mean

Mean…


ทำภาพให้ราบเรียบ ดูนุ่มนวลด้วยการแทนที่ pixel ปัจจุบันด้วยค่า เฉลี่ย ของ pixel รอบข้าง


ตัวอย่าง


การใช้คำสั่ง



ผลลัพธ์




วันพฤหัสบดีที่ 20 เมษายน พ.ศ. 2560

Custom Filter สำหรับการเลือก filter ให้กับภาพ ด้วยการจับคู่ภาพทำ filter

Custom Filter…


เป็นคำสั่งใช้งาน Fourier space filtering โดยการกำหนด spatial domain (non-FFT) ด้วยผู้ใช้งานเอง ด้วยการกำหนดภาพที่จะทำการปรับ  filter จำนวน 2 ภาพ สามารถเลือกเอา filter ของอีกภาพมาใช้กับอีกภาพได้

ภาพจะถูกกำหนดเป็นภาพแบบ 8-bit  สำหรับค่า pixel ที่มีค่าเป็น 0 จะไม่นำมาใช้ ถ้าค่า pixel  เป็น 255 ควรจะนำมาใช้สำหรับการสร้าง spatial frequencies โดยไม่ลดทอนความชัดเจนของพื้นหลัง เป็นวิธีการสร้างการกรอง (filter) ด้วยการวิเคราะห์ความสมมาตรวัดจากจุดศูนย์กลาง จุดที่อยู่ตรงข้ามของจุดศูนย์กลาง (กำหนดด้วย x = width/2, y = height/2) และควรจะถูกปรับเป็นค่าเดียวกัน กรณีอื่น ๆ จะมีเส้นขอบหลังการประมวลผลเกิดขึ้น สำหรับตัวอย่างเพิ่มเติมดูได้จาก

http://imagej.nih.gov/ij/macros/FFTCustomFilterDemo.txt  แสดงตัวอย่างได้ดังด้านล่าง

// This macro demonstrates how to use the Process>FFT>Custom Filter command
  // delete any existing filter
  if (isOpen("Filter")) {
      selectWindow("Filter");
      run("Close");
  }
  // Create filter
  // Note that the filer does not have to be the same size as the image
  size = 256;
  newImage("Filter", "8-bit black", size, size, 1);
  radius = size/10;
  makeOval(getWidth/2-radius, getHeight/2-radius, radius*2, radius*2);
  setForegroundColor(255, 255, 255);
  run("Fill");
  run("Select None");
  run("Gaussian Blur...", "radius="+0.9*radius);
  //run("Size...", "width=512 height=512  interpolate");
  filter = getImageID();
  // Create profile plot of filter
  makeLine(0, 127, 255, 127);
  run("Plot Profile");
  run("Duplicate...", "title='Profile of Filter'");
  selectWindow("Plot of Filter");
  run("Close");

 // Open a sample image and do low-pass filtering
  run("Bridge (174K)");
  //run("Boats (356K)");
  //run("Mandrill (70K)");
  //run("Lena (47K)");
  image = getImageID();
  run("Duplicate...", "title='Low-pass Result'");
  run("Custom Filter...", "filter=Filter");
  run("Enhance Contrast", "saturated=1  ");
  // Do high-pass filtering
  selectImage(filter);
  run("Invert");
  selectImage(image);
  run("Duplicate...", "title='High-pass Result'");
  run("Custom Filter...", "filter=Filter");
  run("Enhance Contrast", "saturated=1  ");
  run(“Tile");

และ
http://imagej.nih.gov/ij/macros/FFTRemoveStreaks.txt และโค้ดได้งตัวอย่างด้านล่าง


// This macro demonstrates an example of Process>FFT>Custom Filter
// command for removing horizontal interference streaks of different
// amplitude in transmission mode confocal images.
// Author: Gilles Carpentier, Faculte des Sciences et
// Technologies,  Universite Paris 12 Val de Marne
// A sample image is available at
//   "http://rsb.info.nih.gov/ij/macros/images/MyoblastCells.tif"
// These are myoblast rat cells in early begining of differentiation,
// in vitro.  Acquisition by Gilles Carpentier. Dr Isabelle Barbosa
// created the cell culture.
// Image acquisition :
// Confocal microscopy images of myoblasts cells were acquired
// with a Zeiss  LSM 410 laser scanning confocal Axiovert 135M
// inverted microscopein in transmission mode with 488 nm
// emission ray of a Ar/Kr  used as lighting, no emission
// filter was used. Debluring was performed before FFT treatment.
//Comments:
// Gilles Carpentier(1), Eric Delechelle(2) and Patrick Karasinski(2)
// (1) Faculte des Sciences et Technologies, laboratoire CRRET,
// CNRS, FRE-2412, Universite Paris 12-Val de Marne,
// 61 Avenue du General de Gaulle, 94010 Creteil cedex, France.
// (2) Faculte des Sciences et Technologies, laboratoire LERISS,
// Universite Paris 12-Val de Marne,
// 61 Avenue du General de Gaulle, 94010 Creteil cedex, France.
//Methods were first developped with The NIH Image software.
//Here is a description of the priciple of the method:
// Removal of artifactual horizontal stripes was performed
// using fast Fourrier transform (FFT):
// First, a fast Harley transform procedure is performed on
// a squared 512x512 image, with swapping the quadrants of
// power spectrum. A filtering using a mask in the frequency
// domain is performed [Bracewell,1984]. The vertical
// rectangular area used as mask, is centred on the vertical
// axis of symmetry, and covers about 1 % of the spectrum. This
// mask, used as a filter (zero value), eliminates the periodic
// structures on the Y axis whatever was their frequencies on
// Y axis, and with a very low frequency in the X axis.
// Furthermore, it centrered the histogram by subtracting
// the mean grey level of the image. The inverse FFT was
// performed after using a gaussian transition [Reeves, 1990].
// The final image was then free of horizontal periodic artefacts.
// References :
// Bracewell, R.N., The Fast Harley Transform,
// Proc. IEEE. Vol. 72, /N8, 1984.
// Reeves A.A. Optimized Fast Hartley Transform for the
// MC68000 with Applications in Image Processing. Master
// of Science Thesis, Thayer School of Engineering.
// Dartmouth College Hanover, New Hampshire, 1990.
// delete any existing Transmission_Filter
  if (isOpen("Transmission_Filter")) {
      selectWindow("Transmission_Filter");
      run("Close");
  }
// Runs faster in batch mode but this requires ImageJ 1.33o or later.
requires("1.33o");
percent = getNumber("Percent of the half vertical axis of power spectra for hight frequencies:", 0.005);
sdhight = getNumber("Standard Deviation of gaussian transition for hight frequencies:", 3.5);
//setBatchMode(true);
// to get the id number the active image to be treated:
// see http://rsb.info.nih.gov/ij/developer/macro/functions.html
imageid = getImageID();
//get the name and dimensions of the active image to be treated
nomdimage = getTitle;
imagey = getHeight();
imagex = getWidth();
// Create mask filter
size =imagex;
newImage("Transmission_Filter", "8-bit black", size, size, 1);
//make a vertical rectangular (3x(size)) mask centered on the filter image
width=3;
halfwidth=(floor(width/2));
//position of the hight left rectangle selection
//((size/2)-halfwidth);
barre(((size/2)-halfwidth),0,width,size);
// gaussian convolution matrix  for a gaussian transition of filter
matrice= matrix(9,40);
selectWindow("Transmission_Filter");
it=4;
for (nconv=0;nconv <it;nconv++) {
run("Convolve...", "text1=["+ matrice+"] normalize");
}
//percent=0.005;
longueur=floor(size*percent);
width=1;
halfwidth=(floor(width/2));
barre(((size/2)-halfwidth),0,width,longueur);
barre(((size/2)-halfwidth),(size-longueur),width,longueur);
//sdhight=3.5;
matrice= matrix(13,sdhight);
run("Convolve...", "text1=["+ matrice+"] normalize");
run("Enhance Contrast", "saturated=0 normalize");
run("Invert");
selectImage(imageid);
run("32-bit");
run("Custom Filter...", "filter=Transmission_Filter");
run("8-bit");
//undo to keep the histogram resulting from the treatment
run("Enhance Contrast", "saturated=0.05 normalize");
exit();

//  function to draw white rectangle
function barre(barx,bary,largbar,hautbar) {
    makeRectangle(barx, bary, largbar, hautbar);
    setForegroundColor(255, 255, 255);
    run("Fill");
    run("Select None");
}
// square function
function carre (car) {
    car= (car * car);
    return car;
}
// gaussian convolution matrix function
function matrix (taille,gauss) {
    matrice="";
    for (j=0; j < taille; j++) {
        lignea="";
        for (i=0; i < taille; i++) {
            numer = -(carre(i-floor(taille/2)) + carre(j-floor(taille/2)));
            denom = 2 * carre(gauss);
            coeff=exp(numer/denom);
            lignea = lignea + " " + coeff;
        }
        matrice = matrice + lignea + "\n";     }
    return matrice;
}

ตัวอย่าง




จากสองภาพข้างบน จะทำการปรับค่าสีท้องฟ้า ด้วยการใช้ filter จากภาพดอกไม้


การเรียกใช้เมนู


เลือกภาพที่ต้องการเป็น filter แล้วกดปุ่ม OK



ผลลัพธ์