現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Does anyone know why the images appear that way?
5 ビュー (過去 30 日間)
古いコメントを表示
The shifted slight translation you'll see in the three plots is correct but why do they appear black and white (duotone)?
They should appear normal grayscale DICOM images. Any idea why this is happening?
I use imtranslate, griddedInterpolant and GridVectors for the translation
14 件のコメント
Anton Semechko
2018 年 7 月 6 日
That will happen in the image has a non-integer format (e.g., double). Try visualizing the image using command
imshow(im,[])
and see if it makes a difference.
Stelios Fanourakis
2018 年 7 月 6 日
No Anton. It wasn't that case. I already use imshow and the uint8() command to bring it back from double. Still I get those white-black images. Do the griddedInterpolant or GridVectors commands alter the image somehow?
Anton Semechko
2018 年 7 月 6 日
I am assuming you were using 'griddedInterpolant' to resample your 3D image (IM). In which case, resampled image (IM2) will be different from IM. The points at which (IM) is being resampled, do any of them fall outside the domain of IM? This is easy to check, because
sum(isnan(IM2(:)))>0
will be true.
Stelios Fanourakis
2018 年 7 月 6 日
@Anton. I get the error
"Error using griddedInterpolant/subsref
Invalid arguments specified in evaluating the interpolant."
Stelios Fanourakis
2018 年 7 月 6 日
@Matt. If I apply what you suggested to the outcome image of your code (result) I get the value ans = 6088652
Image Analyst
2018 年 7 月 6 日
I don't see three plots. I see 4 images, at least what I think are images - I guess then could be plots if you used bar() and patch() or something. The lower right image is a surface rendering of a 3-D image volume. Where are the plots?
And post an image of what the normal (not "duotone") images should look like.
Stelios Fanourakis
2018 年 7 月 6 日
The three are stack of images created by subplots. The individual slices of the stack are translated to a few mm. The normal should look like this (see attached)
Matt J
2018 年 7 月 6 日
Well, we need to have some data and code. Please show the lines of code that are displaying the image slices. Also, please attach those particular slices as matrices in a .mat file.
Jan
2018 年 7 月 11 日
I already use imshow and the uint8() command to bring it back from double
Do you mean:
imgUINT8 = uint8(imgDOUBLE * 255)
? Or did you omit the scaling?
Jan
2018 年 7 月 12 日
編集済み: Jan
2018 年 7 月 12 日
@Stelios: Do you see the problem? You have posted "use imshow and the uint8() command" and only by bold guessing, what this could mean, a substantial problem has been found. Please, Stelios, care for posting the required details, most of all the relevant part of the code.
"I still get a wrong outcome" does not allow to help you. We cannot read your mind or guess, which detail is wrong or what you consider to be right.
The new screenshots look much more like something I'd expect. So I think your former code to convert between double and uint8 contained a bug. Maybe there is another bug also.
Stelios Fanourakis
2018 年 7 月 12 日
@Jan. I have sent all my resources (m files, fig, images) previously so you can assess them. If you have not received them, please let me know, to re send them. It is obvious what the problem is. I want normal grayscale DICOM images, NOT black and white lines. I want to "open" somehow the stack and translate every slice individually based on the 2nd column of the txt file I have sent. It is that simple. Do you need all the resources again so you can give me a valuable answer?
回答 (4 件)
Image Analyst
2018 年 7 月 7 日
No, you didn't try Anton's suggestion because you said "I already use imshow and the uint8() command to bring it back from double. " Well sorry but that won't correct the problem. You have a double image, and imshow() without any [] expects that the range of the image will be between 0 and 1. Anything less than 0 will show up as black and anything more than 1 will show up as white. Your data is fine and good, it's just not being displayed properly. Why don't you at least try to show it with []. Please just humor us and try it:
maxValue = max(im(:)) % Don't use a semicolon
maxValue = min(im(:)) % Don't use a semicolon
imshow(im, []);
What does it show in the command window for the max and min? And do the images now look good? If not, save the image to a .mat file and attach it with the paper clip icon.
13 件のコメント
Stelios Fanourakis
2018 年 7 月 7 日
編集済み: Matt J
2018 年 7 月 7 日
@ImageAnalyst. I get those values:
maxValue =
1.0393e+10
minValue =
-50176048
But whenever I use imshow with [] I get the error "Too many input arguments."
Stelios Fanourakis
2018 年 7 月 7 日
@Matt. Sorry for that. I regularly change the code to find out the problem. Now I turned into uint8 again and I got those values:
maxValue =
uint8
255
minValue =
uint8
0
Still same problem.
Image Analyst
2018 年 7 月 7 日
Try this:
figure;
histogram(im);
figure;
im = mat2gray(im);
Whether mat2gray() works well depends on your distribution since it scales the min to 0 and the max to 1, but if you have a real outlier, it would squish the resulting image into a narrow range so that's why I wanted to check the histogram first. Post a screenshot of the histogram.
Stelios Fanourakis
2018 年 7 月 7 日
@ImageAnalyst. I got only one histogram. The mat2gray figure comes empty. What I realized is that the 4D Dicom image becomes binary at the double() stage (before I make it as input to the griddedInterpolant) but at least it keeps its shape and later on it becomes a shapeless b&w image. Can you guess what is happening? Does the griddedInterpolant or GridVector affect it somehow? If yes how do I reverse it?
Image Analyst
2018 年 7 月 7 日
Your data distribution is really wacky. The scaled version is not all zeros but you just can't see it because almost all the pixels are very very close to the minimum value and you have the largest value that is way, way brighter than most of your pixels. I suggest you use imadjust() if you want to see it look nice.
imshow(imadjust(im));
If you want you can specify a fraction of the histogram tails you want to come in on rather than the default of 1%. From the help:
J = imadjust(I) maps the intensity values in grayscale image I to new values in J. By default, imadjust saturates the bottom 1% and the top 1% of all pixel values. This operation increases the contrast of the output image J.
Stelios Fanourakis
2018 年 7 月 7 日
@Matt. This is the histogram I get from the image after coverting it to double. It looses a lot of its gray tone distribution. GriddedInterpolant needs a double to work. Do you know any other way to make it work without losing such a detail?
Matt J
2018 年 7 月 7 日
I don't really see why the histogram would change simply by converting to double...
Stelios Fanourakis
2018 年 7 月 15 日
@Matt. I though of another solution. When I use result = F(g) I apply interpolation again to g which are the original set points (image) multiplied by translation_vector.
That means that the original image has already been shifted plus a new interpolation coming on the way (F(g)). Does it make it somehow to be smushed or squeezed?
If I visualize with only g without F(g) I get errors later on to the uicontrol of the slider (e.g. Index Exceeds Matrix Dimensions).
Would it be correct to visualize only with g?
Stelios Fanourakis
2018 年 7 月 7 日
編集済み: Image Analyst
2018 年 7 月 7 日
But it does. Before I apply the double() it is a normal grayscale pic. After double(), it becomes white with shapes.
And the result is just a plain white image.
12 件のコメント
Image Analyst
2018 年 7 月 7 日
No. You just totally don't understand how images are displayed. I tried to explain it to you but I guess I didn't do a good job. You can display your data both with range scaling and/or type conversion or without - you just have to do it correctly.
Why don't you just attach your array variable in a .mat file and I'll make a little demo for you?
Stelios Fanourakis
2018 年 7 月 8 日
I use those lines for displaying:
data = dlmread('imgpositions.txt');
[row, col] = size(data);
translation_vector=[col,row,0,0];
t = im2double(im2)/255
F=griddedInterpolant(t);
g=F.GridVectors;
for i=1:numel(g)
g{i}=g{i}*translation_vector(i);
end
result=F(g);
r=im2uint8(255*result)
MyMatrix = r
im2 = MyMatrix
The translation parameters are loaded by a txt file. I tried your imadjust suggestion but didn't work. I didn't get any useful information out of imadjust.
Matt J
2018 年 7 月 8 日
In any case, if your histogram really did change after conversion to double, I think we've answered your question about whether imtranslate, griddedInterpolant or any other transformations afterward were responsible - probably not. Clearly something strange happened in your conversion to double because, as I'm sure you must understand, such a conversion should not change the histogram.
Stelios Fanourakis
2018 年 7 月 8 日
I cannot confirm because as I told you Matt, after double conversion the image became white and after the rest it just became useless. Before the double conversion the image is normal. I don't know what the problem might be.
Image Analyst
2018 年 7 月 8 日
I know what the problem is. Matt knows what the problem is. Anton knows what the problem is. I'm about to give up even trying to explain it to you because after so many replies back and forth you still won't attach your data.
You gave code above. Do you think we can run it? No. We can't. Why not? You're not giving us 'imgpositions.txt'. Maybe it's secret or proprietary - I don't know - but that's fine if it is. Good luck though.
Stelios Fanourakis
2018 年 7 月 8 日
Sorry for that Image Analyst. I though it wasn't that important as I described that the imgpositions.txt contains two columns and 15 rows (same number as images) that denotes the translation of the images. Difference to a few mm. I attach it here, if that will make you help me more.
Image Analyst
2018 年 7 月 8 日
Your code doesn't run. In your code you gave above, what is im2?
t = im2double(im2)/255
Is that the old name of a variable that you renamed? Or the name of a variable created in the base workspace by another m-file?
Perhaps you should call "clear all" or "clearvars" and then try to run your code. Then give us the fixed code where it creates im2.
Stelios Fanourakis
2018 年 7 月 8 日
No. im2 is my original 4D image. I used your code like this
imSize = size(im2);
for k = 1 : imSize(4)
% Extract one 3-D image from the 4-D image.
thisImage3D = im2(:, :, :, k);
% Now determine translation parameters somehow
transformedImage3D = imtranslate(thisImage3D,translation_vector(1:3)); % You write this...
% Now apply those paramters to this 3-D image we extracted.
% Again you write this function.
% Stick it back in im
im2(:,:,:,k) = transformedImage3D;
end
where translation_vector = [col,row,0,0] and col,row are loaded from the txt file ([col row]=size(data))
I get a certain degree of translation, for the whole stack of images. Not individual images. The translation is fixed and do not alter or change for the entire image. I want for every image the translation to be altered. For instance, if I change the values in the txt file and instead of -1, I put -10 the I must have a bigger translation of the correspoding image (slice).
I want it to look like the examp4.jpg I attached at the beggining of this post. The translation looks right but the image do not appear as they are. That is my concern.
Stelios Fanourakis
2018 年 7 月 11 日
Gosh! I wouldn't expect to be that difficult. I know it's just a problem with the image display but nobody seems to find that.
Stelios Fanourakis
2018 年 7 月 15 日
I have another assumption. im2 is a 4D interpolated stack of images (stack out of 15 images) using interp3.
Interpolation to me, means that it creates in between images. For example, if there is 1 to 2 image, the interpolation will give us 1.5 image. Am I correct? So that's what interp3 does. It increases the number of images above 15, where they really are.
Then, by importing im2 to GriddedInterpolant, again another interpolation takes place, so even more subimages are created. Thus, the total number of slices that consist the stack may exceed 30, but, definitely it won't be 15 where it started.
Then, with GridVectors I turn it to cell array and by multiplying with the translation_vector, supposedly they are shifted. BUT, the translation_vector matrix is consisted out of 15 rows and 2 columns. 15 rows as the original images NOT the interpolated ones. So, a lot of images do not shift.
Am I right to my assumption. Is this more clear so we can find a solution?
Stelios Fanourakis
2018 年 7 月 11 日
I wonder, do I have to pay to get a solution?
1 件のコメント
Stelios Fanourakis
2018 年 7 月 15 日
I have another assumption. im2 is a 4D interpolated stack of images (stack out of 15 images) using interp3.
Interpolation to me, means that it creates in between images. For example, if there is 1 to 2 image, the interpolation will give us 1.5 image. Am I correct? So that's what interp3 does. It increases the number of images above 15, where they really are.
Then, by importing im2 to GriddedInterpolant, again another interpolation takes place, so even more subimages are created. Thus, the total number of slices that consist the stack may exceed 30, but, definitely it won't be 15 where it started.
Then, with GridVectors I turn it to cell array and by multiplying with the translation_vector, supposedly they are shifted. BUT, the translation_vector matrix is consisted out of 15 rows and 2 columns. 15 rows as the original images NOT the interpolated ones. So, a lot of images do not shift.
Am I right to my assumption. Is this more clear so we can find a solution?
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)