Inserting NaN's into the Image with data of type single
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sai Prakash Reddy Konda
am 9 Nov. 2018
Kommentiert: Walter Roberson
am 16 Nov. 2018
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..
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 9 Nov. 2018
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 Kommentare
Walter Roberson
am 16 Nov. 2018
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.
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!