Create a phantom image

I am trying to create a phantom image for my Shepp-Logan image. It needs to be 200 by 200 pixels. I have used this code:
P = phantom('Modified Shepp-Logan',100); imshow(P)
And am coming out with this error: Index exceeds matrix dimensions.
Would anyone be able to explain why/what this error is, and how I can fix it?

9 件のコメント

Rik
Rik 2017 年 10 月 31 日
If you need 200x200, why do you enter 100 as a parameter? Other than that, I see no obvious error. Are you certain you didn't overwrite phantom with a variable or another function? (you can run which -all phantom to check that)
Asima Warner
Asima Warner 2017 年 10 月 31 日
My mistake. I actually did type 200 in Matlab and 100 here. May I ask what it means to overwrite phantom? I'm pretty new to this.
Rik
Rik 2017 年 10 月 31 日
If you have written a function yourself and saved it as phantom.m, or if you have a variable/anonymous function with the name phantom, Matlab might try to access one of those, instead of the built-in function. And unless one of those replicates all the necessary behavior, that would result in an error. Otherwise, I can't think of any reason why that would happen.
Asima Warner
Asima Warner 2017 年 10 月 31 日
I don't believe I have on this project. I have on previous ones. Would that be affecting the phantom function?
Rik
Rik 2017 年 10 月 31 日
Variables and anonymous functions need to be in your workspace to have any effect, but function files will have an impact, because Matlab has no way of telling which one you want to call.
Asima Warner
Asima Warner 2017 年 10 月 31 日
I actually have used something named phantom on this project. I used in image called phantom.JPG, but this is the code I have for it:
load phantom.JPG
RGB = imread('phantom.JPG');
imshow(RGB)
I = rgb2gray(RGB);
figure
imshow(I)
Would this be affecting it at all?
Rik
Rik 2017 年 10 月 31 日
No, only a variable or .m file can affect this. If you only run this code after you cleared all variables, do you still get an error?
Asima Warner
Asima Warner 2017 年 10 月 31 日
I ended up changing the name of the image, just in case. I am still getting the error even after I cleared the variables and only run that code. It is still saying the index exceeds matrix dimensions.
Rik
Rik 2017 年 11 月 1 日
Can you show the output of these two lines of code before and after you try to run you code?
which -all phantom
which -all P

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

質問済み:

2017 年 10 月 31 日

コメント済み:

Rik
2017 年 11 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by