Extract image sequence with only 1 color chanel out of rgb avi movie with VirtualDub [closed] - virtualdub

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have an uncompressed RGB AVI file which containes 10 greyscale images: https://drive.google.com/open?id=0B9wKP6yNcpyfY1JzdmJTcHhjTmM (10 images)
With VirtualDub I would like to extract the images whicht should have only 1 channel. I all cases that I tried the images have always 3 channels.
How can that be done?

If you need to do this often your option is "export via external encoder" with VirtualDub FilterMod https://sourceforge.net/projects/vdfiltermod
(rgb export was not possible with official VirtualDub)
the preset below will save gray tiff sequence using ffmpeg (download ffmpeg.exe and replace path to it)
{
"description": "VirtualDub external encoder profile collection",
"externalEncoders": {
"sets": {
"tiff_gray": {
"videoEncoder": "tiff_gray",
"audioEncoder": "",
"multiplexer": "",
"description": "",
"extension": "",
"processPartial": false,
"useOutputAsTemp": true
}
},
"profiles": {
"tiff_gray": {
"name": "tiff_gray",
"program": "E:\\download\\vd\\ffmpeg\\ffmpeg.exe",
"commandArguments": "-f rawvideo -pix_fmt %(pix_fmt) -s %(width)x%(height) -r %(fpsnum)/%(fpsden) -i - -pix_fmt gray8 %(tempvideofile)_%%04d.tif",
"outputFilename": "",
"type": 0,
"pixelFormat": "bgra",
"inputFormat": 0,
"checkReturnCode": true,
"logStdout": true,
"logStderr": true,
"bypassCompression": false,
"predeleteOutputFile": true
}
}
}
}

Related

With the Google Slides API is there a ways to know the height of the text in a shape?

I want to have a shape with text where the text fits neatly inside the shape. To do this I need to know how tall the text in a textElement will be inside a given shape, is there a way to do this?
Answer:
You can get the information of the font size of text inside a Shape using presentations.get with a field mask.
More Information:
The structure of a Shape with text is as follows (irrelevant fields omitted):
{
"shapeType": enum (Type),
"text": {
"textElements": [
{
"textRun": {
"style": {
"fontSize": {
"magnitude": 18,
"unit": "PT"
},
}
},
}
],
},
...
}
You can get this with the field mask:
slides/pageElements/shape/text/textElements/textRun/style/fontSize
Example Request:
slides.presentations.get({
"presentationId": "1x1iiFW0TbP3yPXRldYogXLEGT-tYfa79a2X8ZDIq8tU",
"fields": "slides/pageElements/shape/text/textElements/textRun/style/fontSize"
});
Note: The API does not return if the text wraps across multiple lines or not. This isn't retrievable due to the nature of font sizes. If the font you were using is a monospace font, it may however be possible to work this out based on the width of the Shape and the width of the characters contained within it.
References:
Text - Page.TextStyle | Slides API | Google Developers
Working with field masks | Slides API | Google Developers

Nested hierarchy view (for comment system) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'd like to implement a commenting system where users can reply to others who've left comments. I'd like to display these comments in a nested hierarchy view, similar to what the reddit app "Apollo" does below:
https://i.imgur.com/JiLLsjs.mp4
As you can see, the comments are sorted in a nested format.
Here is what my API response looks like:
{
"success": true,
"data": {
"comments": {
"data": [
{
"id": 1,
"parent_id": 0,
"depth": 0,
"message": "1",
"children_count": 2,
"children": [
{
"id": 2,
"parent_id": 1,
"depth": 1,
"message": "2",
"children_count": 1,
"children": [
{
"id": 3,
"parent_id": 2,
"depth": 2,
"message": "3",
"children_count": 0,
"children": []
}
]
},
{
"id": 4,
"parent_id": 1,
"depth": 1,
"message": "2",
"children_count": 0,
"children": []
}
]
},
{
"id": 5,
"parent_id": 0,
"depth": 0,
"message": "1",
"children_count": 0,
"children": []
}
]
}
}
}
As you can see, each comment object has a parent_id (the parent comment ID), a depth (basically the "level" of the comment in the hierarchy), a children_count (the number of direct children), and children (the children comments themselves).
So with that, my questions are:
How would this best be implemented? As a table view, collection view, or something else? I assume I would create a xib for the comment view itself?
What is the best way to approach actually implementing this? How should I loop through the API response?
How do I add a margin/padding to the left side to make a comment look nested?
How do I make the cells expandable?
What should I know about in terms of memory management?
Thanks.
1- Personally would go with a tableView
2- It's a recursive operation that ends with let children: [Datum]? being empty/nil like
// MARK: - Empty
struct Root: Codable {
let success: Bool
let data: DataClass
}
// MARK: - DataClass
struct DataClass: Codable {
let comments: Comments
}
// MARK: - Comments
struct Comments: Codable {
let data: [Datum]
}
// MARK: - Datum
struct Datum: Codable {
let id, parentID, depth: Int
let message: String
let childrenCount: Int
let children: [Datum]?
}
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let res = decoder.decode(Root.self, from:data)
3- You need to limit the number of replies to a comment , as there is no screen width will fit for un-known number of replies btw it's about nested tableView padding
4- You need to play with heightForRowAt or you'll have to do some calculations for the nested tables or better fixed height with more , also more easier is to show nested comments inside another separate vc and so like facebook
5- Simply don't nest multiple vcs over each other with a count more than 2/3 also using table cells are dequeued which is a good memory performance handled automatically by system

Vanishing when using the price difference

With a team, we are studying how it is possible to predict the price movement with high-frequency. Instead of predicting the price directly, we have decided to try predicting price difference as well as the features. In other words, at time t+1, we predict the price difference and the features for time t+2. We use the predicted features from time t+1 to predict the price at time t+2.
We got very excited, because we thought getting good results with the following graph
We got problems in production and we wasn't known the problem till we plot the price difference.
Here is the content of the config file
{
"data": {
"sequence_length":30,
"train_test_split": 0.85,
"normalise": false,
"num_steps": 5
},
"training": {
"epochs":200,
"batch_size": 64
},
"model": {
"loss": "mse",
"optimizer": "adam",
"layers": [
{
"type": "lstm",
"neurons": 51,
"input_timesteps": 30,
"input_dim": 101,
"return_seq": true,
"activation": "relu"
},
{
"type": "dropout",
"rate": 0.1
},
{
"type": "lstm",
"neurons": 51,
"activation": "relu",
"return_seq": false
},
{
"type": "dropout",
"rate": 0.1
},
{
"type": "dense",
"neurons": 101,
"activation": "relu"
},
{
"type": "dense",
"neurons": 101,
"activation": "linear"
}
]
}
}
How can we fix the problem of the vanishing price difference?
Predicting the next price to within 1% or so is very easy. You could just use the old price as a prediction and achieve 1%. Prices don't change very fast. Therefore, the next price is almost always very close to the last price. The model has picked up on that.
I guess your model learned almost nothing except the very simple relationship that the next price is close to the last price. There is not necessarily anything wrong with your model. Predicting stock prices should be a very hard problem. The solution to this problem would make you rich. It is that hard.

how to make a scatter with regression line graph in amcharts / highcharts?

I read all amcharts and highcharts demo and cant figure out how to draw chart like
The issue I am having is the X axis is text, not numeric like most amcharts/highcharts demos are.
It doesn't matter that you have categories on the x axis, as far as the scatter plot is concerned - your x values are the array index of the categories (0-5 in the case of your image).
There is a plugin to auto calculate a regression line, here:
http://www.highcharts.com/plugin-registry/single/22/Highcharts%20regression
Or, you can calculate your own and plot it normally.
However, a regression line through a group of categories doesn't make much sense. I don't see how it can tell you anything useful, and is probably more likely to cause confusion or outright misunderstanding.
This seems to me to be data that would be more appropriate to plot with a bar chart than a scatter plot.
FWIW
{{edit:
After looking at this longer, I am somewhat unclear: is that actually a regression line, or is that an average, or a target...?
If that's the case, you can either plot it is a line series, or you can use plotLines:
http://api.highcharts.com/highcharts#yAxis.plotLines
Example with a plotLine:
http://jsfiddle.net/jlbriggs/3d3fuhbb/63/
The chart like this is very easily done using amCharts regular Serial chart with line graph with bullets (bullet: "diamond") and no line (lineAlpha: 0).
var chart = AmCharts.makeChart( "chartdiv", {
"type": "serial",
"dataProvider": [ {
"category": "Civil",
"value": 0.87
}, {
"category": "Piping",
"value": 1.1
}, {
"category": "Mechanical",
"value": 0.69
}, {
"category": "Electrical",
"value": 0.82
}, {
"category": "Insulation",
"value": 1.42
}, {
"category": "Completion",
"value": 1.1
} ],
"valueAxes": [ {
"guides": [{
"value": 1,
"lineAlpha": 1,
"lineThickness": 2,
"lineColor": "#f00"
}]
} ],
"startDuration": 1,
"graphs": [ {
"lineAlpha": 0,
"bullet": "diamond",
"valueField": "value",
"lineColor": "#5782bf"
} ],
"chartCursor": {
"categoryBalloonEnabled": false,
"cursorAlpha": 0,
"zoomable": false
},
"categoryField": "category",
"categoryAxis": {
"gridPosition": "start",
"gridAlpha": 0,
"tickPosition": "start"
}
} );
<script src="http://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="http://www.amcharts.com/lib/3/serial.js"></script>
<div id="chartdiv" style="width: 600px; height: 200px;"></div>

Highcharts - Show Year label in x-axis on change [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a scenario where I only want to include the year in the label when it is changed e.g.
Jan-2011, Feb, Mar,..... Jan-2012, Feb, Mar,....
How can I achieve that?
You can use a custom xAxis.labels.formatter:
xAxis: {
type: 'datetime',
tickInterval: 2678400000, //tick every month
labels:{
formatter: function() {
var d = new Date(this.value);
if (d.getUTCMonth() == 0){
return Highcharts.dateFormat("%b-%Y",this.value); // if jan display yeat
}else{
return Highcharts.dateFormat("%b",this.value); // just month
}
}
}
},
Fiddle here.

Resources