Round RBG values to nearest multiple of 50

조회 수: 15 (최근 30일)
Lauren Harkness
Lauren Harkness 2017년 11월 8일
답변: OCDER 2017년 11월 8일
I have an image I am trying to edit, how would I go about rounding each RBG value to it's nearest multiple of 50 (0, 50,100,150,200, and 250)? I am using a for loop right now that spans the size of the image but I can't figure out if I can use the round function for this or not.

답변 (1개)

OCDER
OCDER 2017년 11월 8일
Try this (no for loop needed):
RGB = [1 51 76 105 145 160 190 205];
RGB50 = round(a/50)*50;
RGB50 =
0 50 100 100 150 150 200 200

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by