2024 ทำไม image processing ต องทำ grayscale

today I treid a python filtering code that supposes to increase the noise in the image(de-noising) for a gray-scale image(medical image) and it's for a skull, the problem is i keep getting colored pixels, i mean the noise increased in terms of colored image, not in grayscale so please help me to make the code filter in gray-scale mode, extra details :

the code :

enter link description to see the filter code

original image :

the de-noised image after applying noise filter :

you can see the problem clearly that when i zoom into the picture i can see the colored pixels, while it supposes to be a gray-scale form

colored pixels in the filtered image :

partial zoom in

full zoom in

so please guess does anybody knows how to edit that code so that it can increase the noise in form of grayscale mode.

asked Dec 7, 2021 at 19:12

7

Your input image is a 3-channel JPEG. Make it greyscale (1 channel) before applying noise then it won't be able to treat the channels differently because there will only be one.

Name

filter()

Class

PImage

Description

Filters the image as defined by one of the following modes:

THRESHOLD Converts the image to black and white pixels depending on if they are above or below the threshold defined by the level parameter. The parameter must be between 0.0 (black) and 1.0 (white). If no level is specified, 0.5 is used.

GRAY Converts any colors in the image to grayscale equivalents. No parameter is used.

OPAQUE Sets the alpha channel to entirely opaque. No parameter is used.

INVERT Sets each pixel to its inverse value. No parameter is used.

POSTERIZE Limits each channel of the image to the number of colors specified as the parameter. The parameter can be set to values between 2 and 255, but results are most noticeable in the lower ranges.

BLUR Executes a Gaussian blur with the level parameter specifying the extent of the blurring. If no parameter is used, the blur is equivalent to Gaussian blur of radius 1. Larger values increase the blur.

ERODE Reduces the light areas. No parameter is used.

DILATE Increases the light areas. No parameter is used.

Examples

  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img1.filter(THRESHOLD, 0.3); img2.filter(THRESHOLD, 0.7); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(GRAY); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(INVERT); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(POSTERIZE, 4); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(BLUR, 6); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(ERODE); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(DILATE); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

Syntax

  • pimg.filter(kind)
  • pimg.filter(kind, param)

Parameters

  • pimg

    PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(GRAY); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

    0 any object of type PImage
  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(GRAY); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

    1

    PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(GRAY); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

    2Either THRESHOLD, GRAY, OPAQUE, INVERT, POSTERIZE, BLUR, ERODE, or DILATE
  • PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(GRAY); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

    3

    PImage img1, img2; void setup() { size(400, 400); img1 = loadImage("flower.jpg"); img2 = loadImage("flower.jpg"); img2.filter(GRAY); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); }

    4unique for each, see above

Toplist

โพสต์ล่าสุด

แท็ก

แปลภาษาไทย ไทยแปลอังกฤษ โปรแกรม-แปล-ภาษา-อังกฤษ พร้อม-คำ-อ่าน lmyour แปลภาษา ห่อหมกฮวกไปฝากป้าmv แปลภาษาอาหรับ-ไทย แปลภาษาอังกฤษเป็นไทย pantip แอพแปลภาษาอาหรับเป็นไทย ค้นหา ประวัติ นามสกุล ห่อหมกฮวกไปฝากป้า หนังเต็มเรื่อง ไทยแปลอังกฤษ ประโยค Terjemahan เมอร์ซี่ อาร์สยาม ล่าสุด แปลภาษาจีน กรมส่งเสริมการปกครองท้องถิ่น ่้แปลภาษา Google Translate ข้อสอบคณิตศาสตร์ พร้อมเฉลย พร บ ระเบียบบริหารราชการแผ่นดิน ระเบียบกระทรวงการคลังว่าด้วยการจัดซื้อจัดจ้างและการบริหารพัสดุภาครัฐ พ.ศ. 2560 วิธีใช้มิเตอร์วัดไฟดิจิตอล สหกรณ์ออมทรัพย์กรมส่งเสริมการปกครอง ส่วนท้องถิ่น ห่อหมกฮวก แปลว่า Bahasa Thailand Thailand translate mu-x มือสอง รถบ้าน การวัดกระแสไฟฟ้า ด้วย แอมมิเตอร์ การ์ดแคปเตอร์ซากุระ ภาค 4 ก่อนจะนิ่งก็ต้องกลิ้งมาก่อน เนื้อเพลง ก่อนจะนิ่งก็ต้องกลิ้งมาก่อน แคปชั่น พจนานุกรมศัพท์ทหาร ภูมิอากาศ มีอะไรบ้าง สถาบันพัฒนาบุคลากรท้องถิ่น อาจารย์ ตจต อเวนเจอร์ส ทั้งหมด เขียน อาหรับ แปลไทย ใบรับรอง กรมพัฒนาฝีมือแรงงาน Google map Spirited Away 2 spirited away ดูได้ที่ไหน tor คือ จัดซื้อจัดจ้าง กินยาคุมกี่วัน ถึง ปล่อยในได้ ธาตุทองซาวด์เนื้อเพลง บช.สอท.ตำรวจไซเบอร์ ล่าสุด บบบย มิติวิญญาณมหัศจรรย์ ตอนจบ รหัสจังหวัด อําเภอ ตําบล ศัพท์ทางทหาร military words สอบ O หยน