How to remove the rounded corners which appear in WKinterfaceTablerows ?
By setting the radius as 0 of the group of row.
Related
I'm using the ios-charts library and I would like to add some horizontal padding to my line charts so that the line does not start immediately at the border of the graph.
This is my current chart:
but I would like the blue line to have some padding as shown below. The rest should remain as it is. The reference gray lines should still take the entire width as they currently do.
I found it. This "padding" is actually ruled by the chart.xAxis.axisMinimum and chart.xAxis.axisMaximum. Those values are automatically set to the data min x and max x.
So if I want a left padding I just have to set a chart.xAxis.axisMinimum
In my case, I want around 10% of the x values to be padded, so I calculate it as
// dates is an array of Date representing my x values
if let maxX = dates
.map(\.timeIntervalSince1970)
.max(),
let minX = dates
.map(\.timeIntervalSince1970)
.min() {
let spanX = maxX - minX
let padding = spanX * 0.1
let axisMinimum = minX - padding
// set the left padding
chart.xAxis.axisMinimum = axisMinimum
}
I am creating a color map for data of size(7x24) that I have , lets replace it with some random numbers
b = randi(50,7,24);
t = imagesc(b,[min(min(b)) max(max(b))]);
now inorder to add annotations I have to know the exact starting and ending point of my axes so that i can add a rectangle to select each point in the image
xPOSITION = get(gca,'Position')
xPOSITION =
0.1300 0.1100 0.7750 0.8150
annotation('rectangle',[0.13 0.11 (0.7750 - 0.13)/24 (0.8150 -0.11)/7],'FaceColor','blue','FaceAlpha',.2)
ok now when i try to add an annotation to the exact starting point of the data , the starting point seem to be fine but the size of the rectangular which should actually be equal to each point is alot smaller
according to my calculation each box is equal to (0.7750 - 0.13)/24 X(0.8150 -0.11)/7 , because the units are normalized , am I doing any mistake in calculation ? or the annotation works in a different way ? any help would be highly appreciated
UPDATE just to test I added 0.11 to each dimension of the annotation and it seem to be the exact size for the reason i cannot figure out
annotation('rectangle',[0.13 0.11 ((0.7750 - 0.13) +0.11)/24 ((0.8150 -0.11)+0.11)/7],'FaceColor','blue','FaceAlpha',.2)
The Position property is the [left bottom width height] not [left bottom right top] as it seems that you're treating it (since you're subtracting element 1 from 3 and 2 from 4). To correctly compute the rect for displaying you'll just want to divide the width and height components by the number of elements in those dimensions.
annotation('rectangle', [xPOSITION(1), xPOSITION(2), ...
xPOSITION(3)/size(b, 2), xPOSITION(4) / size(b,1)])
Or more simply:
annotation('rectangle', xPOSITION ./ [1 1 fliplr(size(b))])
That being said, if you're simply wanting to draw rectangles on your data, you're likely better off just creating a rectangle object which is automatically in the units of your data
rectangle('Position', [0.5 6.5 1 1], 'LineWidth', 5)
I need to remove horizontal and vertical lines in a binary image. Is there any method for filtering these lines? bwareaopen() is not good method to remove these lines and also Dilation and Erosion are not good for these cases.
Does any one know a solution?
Example image:
EDIT:(added more example images:
http://s1.upload7.ir/downloads/pPqTDnmsmjHUGTEpbwnksf3uUkzncDwr/example%202.png
source file of images:
https://www.dropbox.com/sh/tamcdqk244ktoyp/AAAuxkmYgBkB8erNS9SajkGVa?dl=0
www.directexe.com/9cg/pics.rar
Use regionprops and remove regions with high eccentricity (meaning the region is long and thin) and orientation near 0 or near 90 degrees (regions which are vertical or horizontal).
Code:
img = im2double(rgb2gray(imread('removelines.jpg')));
mask = ~im2bw(img);
rp = regionprops(mask, 'PixelIdxList', 'Eccentricity', 'Orientation');
% Get high eccentricity and orientations at 90 and 0 degrees
rp = rp([rp.Eccentricity] > 0.95 & (abs([rp.Orientation]) < 2 | abs([rp.Orientation]) > 88));
mask(vertcat(rp.PixelIdxList)) = false;
imshow(mask);
Output:
If all of your images are the same where the horizontal and vertical lines are touching the border, a simple call to imclearborder will do the trick. imclearborder removes any object pixels that are touching the borders of the image. You'll need to invert the image so that the characters are white and the background is dark, then reinvert back, but I'm assuming that isn't an issue. However, to be sure that none of the actual characters get removed because they may also be touching the border, it may be prudent to artificially pad the top border of the image with a single pixel thickness, clear the border, then recrop.
im = imread('http://i.stack.imgur.com/L1hUa.jpg'); %// Read image directly from StackOverflow
im = ~im2bw(im); %// Convert to black and white and invert
im_pad = zeros(size(im,1)+1, size(im,2)) == 1; %// Pad the image too with a single pixel border
im_pad(2:end,:) = im;
out = ~imclearborder(im_pad); %// Clear border pixels then reinvert
out = out(2:end,:); %// Crop out padded pixels
imshow(out); %// Show image
We get this:
You can firstly find the horizontal and vertical lines. Since, the edge map will also be binary so you can perform a logical subtraction operation in between the images. To find vertical lines, you can use (in MATLAB)
BW = edge(I,'sobel','vertical');
For horizontal lines, you can use
% Generate horizontal edge emphasis kernel
h = fspecial('sobel');
% invert kernel to detect vertical edges
h = h';
J = imfilter(I,h);
Does anyone know how to trim an image (uiimage or cgimage). By trim I mean programatically cropping to the non-transparent bounds of an image. So if I have the image below:
00111000
00010000
01011110
00000000
it would yield:
011100
001000
101111
Sum all rows and all columns of your image. You'll get two arrays, in your example looking like this:
3 1 5 0
0 1 1 3 2 1 1 0
Then the first non-zero from the left and the last one near the right is where you have to crop, in each direction.
I have a custom UIView which is drawn using its -[drawRect:] method.
The problem is that the anti-aliasing acts very weird as black lines horizontal or vertical lines are drawn very blurry.
If I disable anti-aliasing with CGContextSetAllowsAntialiasing, everything is drawn as expected.
Anti-Aliasing:
alt text http://dustlab.com/stuff/antialias.png
No Anti-Aliasing (which looks like the expected result with AA):
alt text http://dustlab.com/stuff/no_antialias.png
The line width is exactly 1, and all coordinates are integral values.
The same happens if I draw a rectangle using CGContextStrokeRect, but not if I draw exactly the same CGRect with UIRectStroke.
Since a stroke expands equal amounts to both sides, a line of one pixel width must not be placed on an integer coordinate, but at 0.5 pixels offset.
Calculate correct coordinates for stroked lines like this:
CGPoint pos = CGPointMake(floorf(pos.x) + 0.5f, floorf(pos.y) + 0.5f);
BTW: Don't cast your values to int and back to float to get rid of the decimal part. There's a function for this in C called floor.
in your view frames, you probably have float values that are not integers. While the frames are precise enough to do fractions of a pixel (float), you will get blurriness unless you cast to an int
CGRect frame = CGRectMake((int)self.frame.bounds..., (int)...., (int)...., (int)....);