多媒體安全 image j macros_change color 指導老師:黃文禎 學生:張舒函 學號:...

17
多多 多多 Image J Macros_Change Color 多多多多 多多多 多多 多多多 多多9724817

Upload: derrick-mitchell

Post on 17-Dec-2015

255 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

多媒體安全Image J

Macros_Change Color

指導老師:黃文禎學生:張舒函學號: 9724817

Page 2: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

setupUndo()Call this function before drawing on an image to allow the user the option of later restoring the original image using Edit/Undo. Note that setupUndo() may not work as intended with macros that call the run() function. For an example, see the DrawingTools tool set.

getPixel(x, y)Returns the value of the pixel at (x,y). Note that pixels in RGB images contain red, green and blue components that need to be extracted using shifting and masking. See the Color Picker Tool macro for an example that shows how to do this.

makeRectangle(x, y, width, height)Creates a rectangular selection. The x and y arguments are the coordinates (in pixels) of the upper left corner of the selection. The origin (0,0) of the coordinate system is the upper left corner of the image.

Page 3: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

setPixel(x, y, value)Stores value at location (x,y) of the current image. The screen is updated when the macro exits or call updateDisplay() to have it updated immediately.

changeValues(v1, v2, v3)Changes pixels in the image or selection that have a value in the range v1-v2 to v3. For example, changeValues(0,5,5) changes all pixels less than 5 to 5, and changeValues(0x0000ff,0x0000ff,0xff0000) changes all blue pixels in an RGB image to red.

ChangeColors// This macro changes the value of pixels in the image// or selection that are in the foreground color to the // background color. Use Edit>Undo to revert back to// the original.

Page 4: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Program Code)macro “Change Colors” { setupUndo(); // (in Edit) isSelection = selectionType!=-1; // 將 selectionType的值指給 isSelection,但不可等

於 -1 value = getPixel(0, 0); // 取得圖片的像素值,並指給 value makeRectangle(0, 0, 1, 1); // 在圖片左上角建立一個矩形選項 run(“Fill”); // 將該方塊物件填滿 (in Edit) foreground = getPixel(0, 0); // 取得填滿後圖片的色彩像素值,並指給 foreground run(“Clear”); // 清除方塊物件 (in Edit) background = getPixel(0, 0); //取得清除後圖片的色彩像素值,並指給 background setPixel(0, 0, value); // 重新設定圖片色彩像素值 if (isSelection) // 若 If條件式成立 (!= -1) run(“Restore Selection”); // 執行”恢復選取” else // 否則 (= -1) run(“Select None”); // 執行”無選取” if (bitDepth==24) { // not needed in ImageJ 1.34n or later (我們使用 1.41n) foreground = foreground&0xffffff; background = background&0xffffff; } changeValues(foreground, foreground, background);}

Page 5: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Open an image : In this case we use Leaf

Page 6: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Change the Image Type into 8-bit Color

Page 7: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Open an image : In this case we use Leaf

Page 8: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Assign a Number of Colors value form 2 to 256

Page 9: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Install Macros that we chose before Run.

Page 10: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Then run the Change Colors Macros

Page 11: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Runing)

Leaf_Assign a Number of Colors in 8

Page 12: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Run the Change Colors Macros on All Leaf

Page 13: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Run the Change Colors Macros on a part of Leaf

Page 14: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Leaf_Assign a Number of Colors in 128

Page 15: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Run the Change Colors Macros on All Leaf

Page 16: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

Macros_Change Color (Steps)

Run the Change Colors Macros on a part of Leaf

Page 17: 多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817

~ The End ~

Thanks For Listening