How would i extract ONLY even numbered elements of an image?

3 ビュー (過去 30 日間)
Jenalyn Palacios
Jenalyn Palacios 2020 年 3 月 5 日
コメント済み: Jenalyn Palacios 2020 年 3 月 5 日
I have an image that I am suppose to `Half' the size of the image (i.e. reducing it to 256x256) by extracting only even numbered elements. This is my code so far:
% Part i.
imgroup0=imread('selfie2.tif');
A1= rgb2gray(imgroup0);
imgroup1=imresize(A1, [512 512]);
% Part ii.
evens=imgroup1(mod(imgroup1,2)==0);
But i dont understand how mod will help me 'extract' the even numbers from the image or how i would display it afterwards. Can someone explain?

採用された回答

Bhaskar R
Bhaskar R 2020 年 3 月 5 日
編集済み: Bhaskar R 2020 年 3 月 5 日
Part ii
% for even values
even_values = imgroup1(mod(imgroup1, 2) == 0);
% for display purpose
evens = imgroup1.*uint8(mod(imgroup1, 2) == 0);
figure, imshow(evens);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by