フィルターのクリア

How to display output image from 'Regionprops'?

11 ビュー (過去 30 日間)
Fahmi Akmal Dzulkifli
Fahmi Akmal Dzulkifli 2022 年 7 月 30 日
Greetings, I have a code like shown as below:
img = imread('I.jpg'); % this image in grayscale
c = 1;
BW = img > 0;
BW = bwareaopen(BW,50);
s = regionprops(BW,img,{'Centroid','MeanIntensity','PixelValues'});
numObj = numel(s);
for k = 1:numObj
s(k).Gamma = round((2.6593.*(s(k).MeanIntensity)+0.3137),1);
s(k).Output = c*(s(k).PixelValues.^s(k).Gamma);
end
I want to ask is there any possible way to display the new image obtained from the s(k).Output?
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 7 月 30 日
Yes, there is a possible way. But that doesn't mean that it is a good idea to proceed this way.
Ask for the Bounding Box and the Image. Use the bounding box to extract original pixels from img. Multiply by cast(Image, class(img)) to get masked pixels. Apply gamma transform to them, making sure to take into consideration whether the pixels are double precision or uint8. You know have a gamma transformed sub-image that you can display
Fahmi Akmal Dzulkifli
Fahmi Akmal Dzulkifli 2022 年 7 月 30 日
Alright Sir. Thank you for the response. Later I will try it

サインインしてコメントする。

採用された回答

Atsushi Ueno
Atsushi Ueno 2022 年 7 月 30 日
> I want to ask is there any possible way to display the new image obtained from the s(k).Output?
You can write only a continuum area in the source image as below. Get 'PixelIdxList' with regionprops function.
img = imread('coins.png'); % this image in grayscale
c = 1;
BW = img > 127; % I have changed the threshold value for coins.png
BW = bwareaopen(BW,50);
s = regionprops(BW,img,{'Centroid','MeanIntensity','PixelValues','PixelIdxList'}); % add PixelIdxList
numObj = numel(s);
for k = 1:numObj
s(k).Gamma = round((2.6593.*(s(k).MeanIntensity)+0.3137),1);
s(k).Output = c*(s(k).PixelValues.^round(s(k).Gamma)); % gamma is rounded to avoid error
img(s(k).PixelIdxList) = s(k).Output;
end
imshow(img)
  1 件のコメント
Fahmi Akmal Dzulkifli
Fahmi Akmal Dzulkifli 2022 年 7 月 30 日
Alright. I already got it. Thank you very much

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by