algorithm help for separating 3d object from ct scan
I did some CT scan on a box of grape, and i need to identify each individual grape bundle. the data is a 3 dimensional logical matrix, in a 3D view will be something looks like the pic attached. and i need to separate each individual grape bundle. I am quite new to image analysis, could someone please give me some hint on how to approach this problem.
See also questions close to this topic
Using Microsoft Paint with Matlab Code
I need to have a few hundred photos manually inspected and edited. Certain things need to be blacken out, while others marked.
I would like to write a script/GUI that will allow me to do the following:
1) Open mspaint
2) load image (uint8 matrix) currently saved in workspace into open window
3) when done editing, close mspaint and save new image into workspace (as uint8 matrix)
to implement this, I wish to know:
How to load an image from workspace into an open mspaint session.
How to save an image from a mspaint session to workspace as uint8 matrix.
How to close mspaint - openning is with "system('mspaint')"
Help would be much appriciated.
Error connecting precision balance to PC via RS232 on Matlab
I have been trying to retrieve mass values from a RADWAG precision balance (model PS 1000/C/2) every 1 second on Matlab via RS232 port. The thing is that after I run the program (and before it asks me to enter the amount of samples & time intervals) it shows the following warning:
Warning: Unexpected Warning: A timeout occurred before the Terminator was reached.
The code I've written so far is the following:
port=serial('COM7'); fopen(port); fgets(port); fclose(port); prompt='How many samples '; samples=input(prompt); prompt='Time interval '; interval=input(prompt); time = zeros(samples,8); mass = char(samples,20); for i=1:samples fopen(port); a=fgetl(port); fclose(port); format shortg clock fprintf('%s \n',a); for j=1:6 results(i,j)= ans(1,j); end for k=1:20 mass(i,k)=a(k); end pause(interval) end
The result it should show is: "year month day hours minutes mass". However, I am getting the following error after entering both the amount of samples and intervals:
Attempted to access a(1); index out of bounds because numel(a)=0. Error in programabalanza (line 33) mass(i,k)=a(k);
It is important to mention that "programabalanza" is the name of the Matlab file. So far I believe the problem is between the instrument and the software, port is working fine. I've done a lot of reading, but I've only found out that
fgetlMatlab function does the job. Can anyone help me? Thanks in advance.
Dealing with nested struct access
What is the best way to avoid writing something like:
someDataStruct.longSubStructName.anotherLongName.theVariable = someStruct.longSubStructName.anotherLongName.theVariable + 10;
Setters and getters would be a work around in oop programs. But what would be the best way to deal with this in for example MATLAB or C without having any objects?
- Segmentation of Signature
Python 3D image segmentation find local peaks in distance map for watershed
I am trying to segment 3d tomographs of porous networks in python. I am able to calculate the distance map with
ndimage.distance_transform_edtand the peaks with
feature.peak_local_max. when I apply the watershed algorithm a get an acceptable result, but the markers of the peaks are not located at the visible peaks, see image, of the distance map
Thanks in advance
Here the code a is the image
D = ndimage.distance_transform_edt(a) localMax = feature.peak_local_max(D, indices=False, min_distance=50, labels=a) localMax2 = feature.peak_local_max(D, indices=True, min_distance=50, labels=a) markers = ndimage.label(localMax, structure=np.ones((3,3,3))) labels = morphology.watershed(-D,markers,mask=a)
Input images into an array
I am solving the following problem: "In the task, we consider a dataset with images which have a resolution of 1920x1080. The data iterator should read in the original images and randomly select a 512x512 patch in the image. Once the data iterator processed 32 images, it should yield a batch with 32 patches. So the data iterator yields tensors with the following dimensions, 32 x 3 x 512 x 512."
Here is the function for creating the patch:
patches= def get_patches(image): # """Get `num_patches` random crops from the image""" patch = tf.random_crop(image, [512, 512, 3]) patches.append(patch) patches = tf.stack(patches)
I tried taking the input like this:
mypath='images' images =  onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ] for n in range(0, 32): images= cv.imread( join(mypath,onlyfiles[n]) )Shape of images is (1000,1000,3).How do I input images so that the array images is of size (32,1000,1000,3) i.e. it contains all the images and I can call function get_patches() for images[n].
Finding bright spots in a image using opencv
I want to find the bright spots in the above image and tag them using some symbol. For this i have tried using the Hough Circle Transform algorithm that OpenCV already provides. But it is giving some kind of assertion error when i run the code. I also tried the Canny edge detection algorithm which is also provided in OpenCV but it is also giving some kind of assertion error. I would like to know if there is some method to get this done or if i can prevent those error messages.
I am new to OpenCV and any help would be really appreciated.
P.S. - I can also use Scikit-image if necessary. So if this can be done using Scikit-image then please tell me how.
Below is my preprocessing code:
import cv2 import numpy as np image = cv2.imread("image1.png") gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) binary_image = np.where(gray_image > np.mean(gray_image),1.0,0.0) binary_image = cv2.Laplacian(binary_image, cv2.CV_8UC1)
How can I convert this simple photoshop workflow to PIL
There is this simple trick in photoshop where you can convert a color image into a line art.
In photoshop the process goes like this: https://youtu.be/aPn55fF-Ntk?t=110 video might be little NSFW at some parts but I linked to the important time stamp which is SFW.
Summary if you don't want to watch the video:
1) Turn your image to grayscale and make a copy
2) Change the mode of the top copy to Color Dodge
3) Invert the top image
4) Add gaussian blur
5) Merge 2 layers
My code is below and I am stuck on step 4. I am not exactly sure how to recreate that step in PIL because I have no idea what photoshop is doing. I am not exactly sure where the gaussian blur is applied to, E.g. do I need to apply gaussian to both the original and the copy then add them together? I am very confused on that part.
import numpy as np from PIL import Image from PIL import ImageFilter import PIL.ImageOps def dodge(front,back): # The formula comes from http://www.adobe.com/devnet/pdf/pdfs/blend_modes.pdf result=back*256.0/(256.0-front) result[result>255]=255 result[front==255]=255 return result.astype('uint8') fname = 'C:/Users/Luke Chen/Desktop/test.JPG' img = Image.open(fname,'r').convert('L') # turn image to grayscale arr = np.asarray(img) img_blur = img.filter(ImageFilter.BLUR) blur = np.asarray(img_blur) result = dodge(front=blur, back=arr) # color doge copy result = Image.fromarray(result, 'L') result = PIL.ImageOps.invert(result) # invert the color doge copy # toDO Do something with gaussian blur?? and merge both images. result.show()
Object detection on test image using MASK RCNN
I am identifying objects using Mask RCNN object detection algorithm. I have already trained the model using my dataset and checked the result using validation dataset. The algorithm link for mask rcnn is below.
My concern is I want to predict the result on an unknown image using model but i dont understand how to change the code for this. The code in the inspect_model.ipynb takes a random image from the validation dataset and do the prediction. But i want to choose image from my own computer system and do the prediction.
Can anyone please tell me the code for that. Thanks in advance.