Clear Filters
Clear Filters

quantize ROI of an image in 3 spaces [0,10),(10,36],(36,255]

1 view (last 30 days)
So i have a greyscale image named (c.png) and a ROI of that image (roi_c.png) The excersise asks me to quantize the ROI of the image in 3 spaces [0,10),(10,36],(36,255] and do some stuff atfer that . my question is how exaclty do I do that? do i use the imquantize function? there is this quant_A = imquantize(A,levels) but as far as i understand levels is the variable that shows in how many levels it will be quantized and if i use 3 it will not be in the spaces that I want. thanks in advance

Answers (1)

Sufiyan
Sufiyan on 2 Mar 2023
Hello,
You can use imquantize function, where you must specify the levels as [10,36] so that it quantizes in to three levels ([0-10], [10-36], [36-255]). You can refer to the code below.
% Load the image
img = imread('img.jpg');
% Define the Region of interest(ROI) of image
roi = img(100:200, 150:450);
% Define the quantization ranges
ranges = [10 36];
% Quantize the ROI
quantized_roi = imquantize(roi, ranges);
% Display the original and quantized ROIs
figure;
subplot(1,2,1);
imshow(roi);
title('Original ROI');
subplot(1,2,2);
imshow(quantized_roi, []);
title('Quantized ROI');
you can go through imquantize to get more information about quantization levels.

Tags

Community Treasure Hunt

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

Start Hunting!