How can I decrease intensity levels?

조회 수: 2 (최근 30일)
Tugce Irem
Tugce Irem 2022년 9월 21일
댓글: Image Analyst 2022년 9월 24일
Hello,
I have RGB images and I got measurements for mean, max, min intensities. I want to decrease 20intensities from each shape in the image without limiting the highest value? For example if the shape has 85pixel at maximum, I want to make it 65, but the other shape has 110 , it should be 90. The blobs are in the same image, I split RGB, and working on only blue and green. Is that possible?
I attached function and one of my merged image, also my single command
Tugce2AnalyzeImage(originalImage, 20, 255)
Thank you
Tugce

답변 (2개)

Image Analyst
Image Analyst 2022년 9월 21일
편집: Image Analyst 2022년 9월 21일
Not sure what "limiting" means to you when talking about uint8 images. The values are limited by 0 so if the value is 15, subtracting 20 will give you 0, not -5. If you still want -5 then you need to cast the values to double. Otherwise you can simply do
[r, g, b] = imsplit(rgbImage);
b = b - 20;
g = g - 20;
rgbImage = cat(3, r, g, b);
  댓글 수: 1
Image Analyst
Image Analyst 2022년 9월 24일
@Tugce Irem I'm still unsure after your comments to Walter what you mean by maximum and limiting. His code and my code both subtract 20, though his calls imclearborder and seems to call regionprops on the green gray scale image rather than a binary image. Anyway since you said that you know one image is just 20 gray levels higher than it should be due to some microscope glitch, why can't you just subtract 20 from the whole image (like Walter showed you at one point) or just only from the green and blue channels like you asked for and I showed you? What are we missing here?

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2022년 9월 21일
newImg = imresize(Img, size(Img, 1:2)-20);
  댓글 수: 6
Tugce Irem
Tugce Irem 2022년 9월 23일
Thank you both, I tried to fixed the question, I attached the code. I was trying not to bother too much with my all codes, I was trying to ask specific question. Unfortunately Mr. Walter Roberson, I didn't understand how I can use this
YourMatrix(ind) = YourMatrix(ind) - 20;
Thanks again
Walter Roberson
Walter Roberson 2022년 9월 23일
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1134565/originalImage.jpg';
rgb = imread(filename);
imshow(rgb);
title('original')
r = rgb(:,:,1);
g = rgb(:,:,2);
b = rgb(:,:,3);
gborderless = imclearborder(g);
g_of_rgb = zeros(size(rgb), 'like', rgb);
g_of_rgb(:,:,2) = gborderless;
imshow(g_of_rgb);
title('green channel')
blobprops = regionprops(g, 'PixelIdxList');
all_used_idx = vertcat(blobprops.PixelIdxList);
r_filtered = r; r_filtered(all_used_idx) = r_filtered(all_used_idx) - 20;
g_filtered = g; g_filtered(all_used_idx) = g_filtered(all_used_idx) - 20;
b_filtered = b; b_filtered(all_used_idx) = b_filtered(all_used_idx) - 20;
rgb_filtered = cat(3, r_filtered, g_filtered, b_filtered);
imshow(rgb_filtered);
title('after intensity adjustment')

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by