フィルターのクリア

Inserting NaN's into the Image with data of type single

1 回表示 (過去 30 日間)
Sai Prakash Reddy Konda
Sai Prakash Reddy Konda 2018 年 11 月 9 日
コメント済み: Walter Roberson 2018 年 11 月 16 日
Hi,
I have an image of size 256 X 256(total number of elements in the image are: 65536). How can insert NaNs into the image alternatively?. That is, every second entry of the image should contain a NaN. Such that no two adjacent pixels should have NaNs.
Kindly help me in this issue.
Thanks in advance..

採用された回答

Image Analyst
Image Analyst 2018 年 11 月 9 日
Try this:
grayImage = single(imread('cameraman.tif'));
[rows, columns, numColors] = size(grayImage)
mask = checkerboard(1, floor(rows/2), floor(columns/2)) == 0;
grayImage(mask) = nan;
imshow(grayImage, [])
  2 件のコメント
Sai Prakash Reddy Konda
Sai Prakash Reddy Konda 2018 年 11 月 16 日
編集済み: Sai Prakash Reddy Konda 2018 年 11 月 16 日
Perfect. Thank you so much Image Analyst.. :) :)
Walter Roberson
Walter Roberson 2018 年 11 月 16 日
grayImage(1:2:end,1:2:end) = nan;
grayImage(2:2:end,2:2:end) = nan;
no function calls needed . This does assume that grayImage is floating point datatype.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by