carrying out simple functions on all cells within an array

4 ビュー (過去 30 日間)
Optical_Stress
Optical_Stress 2017 年 4 月 6 日
コメント済み: Optical_Stress 2017 年 4 月 6 日
Hi,
I have a 5x1 cell containing 'images' (arrays of their intensities). I want to carry out a 'normalisation'. I want to divide the every array in the cell by a constant, this has been successful using:
Normalised_Cell=cellfun(@(v) v./N,B,'UniformOutput',false)
N is the largest value in the first array.
However, the arrays are returning 0 and not the decimal values. For example, If i have a maximum of 180 and the first cell contains 3 (or 50 or 100), the matrix will show 0 instead of 3/180. I suspect that this is due to the fact that the arrays in the cell are uint8. But i'm not sure how to go about fixing this.
I then want to square-root the values, and following that take the inverse sine.
Will cellfun suffice when applying inverse sin to these uint values?

採用された回答

Jan
Jan 2017 年 4 月 6 日
編集済み: Jan 2017 年 4 月 6 日
Use double instead:
Normalised_Cell = cellfun(@(v) double(v) ./ double(N), B, 'UniformOutput', false)
  3 件のコメント
Jan
Jan 2017 年 4 月 6 日
Try it:
uint8(3) / uint8(180)
This is smaller than 1 and the next possible value is uint8(0). For arithmetic operations it might be useful to convert all images by im2double at first.
Optical_Stress
Optical_Stress 2017 年 4 月 6 日
Yeah, just read about uint8, makes a lot more sense now, thanks.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by