what does imloadfunc do?

I 'm working on non-negative matrix factorization. I have come across a GitHub code for the same. Here, they have used global imloadfunc .im unable to understand why it is been used.

回答 (1 件)

Guillaume
Guillaume 2017 年 8 月 17 日

0 投票

That global variable imloadfunc is s switch that tells which function to use to read images. If it is set to 'pgma_read', then it'll use that function. In any other case, it'll use the standard imread function.
It's a bad way of programming, there a much better mechanism in matlab for this such as getpref. Hopefully, that global variable is set by whatever starting code there is as if it does not exist your linked function will error.
If it's not set, you can always do:
global imloadfunc;
imloadfunc = ''; %to use default imread
at the command prompt.

4 件のコメント

kitty varghese
kitty varghese 2017 年 8 月 17 日
when I'm trying to execute this code. I'm getting error SWITCH expression must be a scalar or string constant.
Guillaume
Guillaume 2017 年 8 月 17 日
So, what is the value of imloadfunc, when you get the error?
kitty varghese
kitty varghese 2017 年 8 月 17 日
編集済み: Guillaume 2017 年 8 月 17 日
im getting
val ''
Guillaume
Guillaume 2017 年 8 月 17 日
Maybe, you're on an older version where '' is not acceptable for switch. A bit odd. You can use any non-empty value,e.g.:
global imloadfunc;
imloadfunc = 'x';

この質問は閉じられています。

質問済み:

2017 年 8 月 17 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by