error in vessel branch segmentation code - matlab

I am struggling with this problem since 2 days. Please help me out on this. I am working on vessel branch segmentation and I have got the code from MathWorks central.
Please download the submission from that site, and open the readme.txt
Before I got an error for converting tiff file to mat file but now it's working. Thank you for the quick reply to my post. But now I am getting the following error
Elapsed time is 0.987052 seconds.
Index exceeds matrix dimensions.
Error in VBSvesselMask (line 20)
meanImg=mean(single(orgImg(:,:,windowSize+1:30)), 3);
Error in VesselBranchSegmentation/CBestimateVesselMask (line 294)
[appImg masks(1).img]= VBSvesselMask(orgImg);
Error while evaluating uimenu Callback
Please help me out.

Use dbstop if error and check the size of orgImg at that point.
It seems the input is expected to be some sort of image stack (3D data or a stack of 2D images, such as a set of 2D images of the same area taken over time). The error indicates that the size of your input image is smaller than what the code expects.
This line of code is the sticking point:
orgImg(:,:,windowSize+1:30)
For this to work, the size of third dimension of orgImg must be at least 30 and the value of windowSize should be appropriately set (somewhere between 0 and 29). Looking at the original code, it appears you are supposed to use the VBSreadtiff function on a entire directory of images, to create an image stack for the code to work on. Using a single grayscale or RGB image will not work.

Related

Why am I getting this The initial magnification of the image is set to 'fit' in a docked figure MATLAB error

I am following this project https://github.com/janstenum/GaitAnalysis-PoseEstimation. I have ran the first command and made it all the way through until I ran into this error:
Warning: The initial magnification of the image is set to 'fit' in a docked figure.
> In imshow (line 322)
In extractScaling_openpose (line 21)
In OpenPoseGaitAnalysis_JS (line 11)
This occurs when it reaches the point in which it needs to run the command
calculate_gaitParameters_jointAngles.m
I have tried rereading the documentation with no result and saving the output and individually running the command on it.
I also tried jsut running the entire sequence through with the initial command
OpenPoseGaitAnalysis_JS
It would end and print that error after I tapped save after it ran the function
extractScaling_openpose
I have no idea whats going on. Please help.

MATLAB Image Processing: Show multiple images

Trying to experiment with MATLAB image filtering.
I take the image, use imshow(img), then apply a filter or some other transformation and call imshow(img) again.
For some reason, MATLAB seems to only display the image once, even if I call imshow or imagesc multiple times.
When I did this in Python, when I closed the image window, then the next image would appear. So I thought that until I closed the image window, code execution would halt. But that does not seem to be the case for MATLAB, as closing the image does nothing.
Anyone know why? Thank you.

Issues opening a .czi file (zeiss microscope file) tile with aicspylibczi

I am trying to open a tiled (mosaic) .czi file with aicspylibczi but I receive the following error message:
"The coordinates are overspecified = you have specified a Dimension or Dimension value that is not valid. Scene index -1 ∉ [0, 0)".
My code is just:
import aicspylibczi
img_tile = path+"JM200718_1_Out.czi"
execute_czi = aicspylibczi.CziFile(img_tile)
, I have not specified any coordinate, and because I can open with no problem .czi files that have 300 z and 2 channels, but only one xy start coodinate (not mosaic files), I feel the probleme lies in the fact that my images are mosaic files.
Does any one has an idea to how to get around that? It is the very first step of my code so I feel stuck in my attempts to see what is the issue here.
All the examples I found, including the specific one for mosaic fils is te one I wrote (witch do not work).
ex: https://pypi.org/project/aicspylibczi/
Thanks for taking the time to read me!

Caffe bvlc_googlenet minimum accepted dimensions

What is the minimum image input size accepted by bvlc_googlenet model implemented by Caffe?
I'm using 50 x 50 images with crop_size = 36, where i get the following error when running the solver:
caffe::Blob<>::Reshape() - Floating point exception
I have to resize my images to 256 x 256 (default input size of the bvlc_googlenet model) with crop_size = 224 to avoid the error.
Do this model only accept its default sizes or i have to hack around a bit to make it happen?
Thanks!!
After several hours of trying to fix the problem, i figured out why i was facing it.
GoogleNet accepts 224*224 images as input by default, so because it is so deep and after a set of convolution and pooling layers, using a 50*50 images (or 36*36 after crop) will lead into a very small sized output, after passing the input into some layers, smaller than the kernel size of the next layer. This will cause a Reshape exception similar to the one i faced here.
Solution:
Although its not preferred to edit the kernel_size param of the layer causing the exception (to keep working up to the NN's specifications), this will fix the problem, Where you could choose a smaller kernel size and then test the results until it works.
Follows the default GoogleNet's specifications by resizing your input images into 254*254 (keeping crop size to 224) or directly changing it to 224*224 and removing the crop_size param.

MATLAB - imwrite error in certain folders

this is my first question so I hope I am writing in the right place.
I am currently working with a Grasshopper3 camera, model: GS3-U3-50S5M-C from Point Grey Research connected to MATLAB.
I am recording a lot of frames at a time in grayscale and in order to avoid filling up my memory I would like to move some of the frames to my disk as stacked TIFFs during the recordings. The stacked TIFF format is needed for other programs used.
I am doing this by moving the recorded frames from the camera to the workspace using getdata. This creates a 4-D uint8 object containing height, width, color plane and frame number of the frames. In order to save the frames as a stacked TIFF I use a for loop with imwrite to save one frame at a time as shown below. However when I do this I most often get the error:
Error using imwrite (line 454) Unable to open file "C:\Users\My_User\Desktop\CraneStuff3\Name.tif" for writing. You might not have write permission.
When this happens MATLAB has typically saved some of the frames, e.g. if I have recorded 500 frames it might save 300 before giving me the error. Sometimes it manages to save every frame with no error, sometimes it only saves 30 frames before failing. I do not understand how it can save some frames and then claim that it cannot open the file for writing.
I have noticed, however, that if I instead save the file in "C:\Users\My_User\Documents\MATLAB" it seems to never give any error and save every frame as wanted.
Does anyone know why this is the case or how I can fix my problem?
I have included my code below here.
Note: I tried saving the frames as a .mat-file. To do this I had to use version '-v7.3' in save.
Thank you advance.
% Connect to camera:
vid = videoinput('pointgrey',1,'F7_Mono8_2448x2048_Mode0');
vid.TriggerRepeat = 100;
vid.FrameGrabInterval = 1;
% Make a recording:
start(vid)
pause(50)
stop(vid)
% Get data from camera to workspace:
data = getdata(vid,vid.FramesAvailable);
% Save data to disk one image at a time:
num = size(data);
output_name = fullfile('C:\Users\My_User\Desktop\CraneStuff3', ['Name' '.tif']);
for k = 1:num(4)
imwrite(data(:,:,:,k),output_name,'WriteMode','append');
end
One possible solution is to try saving each of the frames separately into a tiff file.
If you save a .mat file, better use savefast