Extracting pixels from an image random
Show older comments
Hello,
How can I extract 100 pixels color randomly from an image ?
Accepted Answer
More Answers (1)
Image Analyst
on 1 Jun 2019
Here is another way:
% Load standard demo RGB image:
rgbImage = imread('peppers.png');
% Extract the individual red, green, and blue color channels:
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Get 100 random locations:
locations = randperm(numel(redChannel), 100)
% Get R, G, and B values at those locations:
redValues = redChannel(locations)
greenValues = greenChannel(locations)
blueValues = blueChannel(locations)
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!