How to reduce random pixel colours in shape and try to blend them together or convert them to average of neighbouring pixels?

4 views (last 30 days)
i want to work out the gradient of colour from this image. so basically im thinking of creating a line or box that starts at e.g. y=0 and goes up until it hits the black colour and it should find pixel colours in terms of whiteness at all points along that line. so it should go from high white pixel values to medium grey pixel values to blackish pixel values. i can use some more basic softwares like imagej to draw a line and plot pixel values but the problem is in my image region of interest there are lots of random pixels with completely different greyness colours so the graph would have lots of noise (go from very high pixel whiteness to sudden low pixel whiteness). i want some way to kind of smooth image or change odd pixels to have same colour as its neughbouring pixels. for smoothing i cant smooth much because essentially i want to get an accuarate plot ofchanging pixel intensity across the line. could anyone siggest some code

Answers (1)

DGM
DGM on 16 Mar 2022
Depending on what you're trying to do and what you expect, look at:
  • imfilter() and fspecial() for various averaging filters
  • imgaussfilt() for 2D gaussian averaging filter
  • medfilt2() for 2D median filter

Community Treasure Hunt

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

Start Hunting!