MATLAB: How to set grayscale just between 100 to 250

digital image processingimage processing

Dear all, Im a newby to matlab.I have 8bit gray scale image "X". I want to set the gray level just between 100 -250. Any respond will be appreciated. Thanks

Best Answer

  • The question is not clear. But let me guess:
    X = randi([0, 255], 640, 480, 'uint8'); % Example image
    X(X < 100) = 100;
    X(X > 250) = 250;
    Or:
    X = min(max(X, uint8(100)), uint8(250));