Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "多媒體安全 Image J Macros_Change Color 指導老師:黃文禎 學生:張舒函 學號: 9724817."— Presentation transcript:

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

2 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.DrawingTools 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.Color Picker Tool 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.

3 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.

4 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); }

5 Macros_Change Color (Steps) Open an image : In this case we use Leaf

6 Macros_Change Color (Steps) Change the Image Type into 8-bit Color

7 Macros_Change Color (Steps) Open an image : In this case we use Leaf

8 Macros_Change Color (Steps) Assign a Number of Colors value form 2 to 256

9 Macros_Change Color (Steps) Install Macros that we chose before Run.

10 Macros_Change Color (Steps) Then run the Change Colors Macros

11 Macros_Change Color (Runing) Leaf_Assign a Number of Colors in 8

12 Macros_Change Color (Steps) Run the Change Colors Macros on All Leaf

13 Macros_Change Color (Steps) Run the Change Colors Macros on a part of Leaf

14 Macros_Change Color (Steps) Leaf_Assign a Number of Colors in 128

15 Macros_Change Color (Steps) Run the Change Colors Macros on All Leaf

16 Macros_Change Color (Steps) Run the Change Colors Macros on a part of Leaf

17 ~ The End ~ Thanks For Listening


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

Similar presentations


Ads by Google